Let $n$ be a positive integer. Let $a, b, c$ be nonnegative integers such that $a + b + c = n$.

Alice and Bob are gonna play rock-paper-scissors $n$ times. Alice knows the sequences of hands that Bob will play. However, Alice has to play rock $a$ times, paper $b$ times, and scissors $c$ times.

Alice wins if she beats Bob in at least $\lceil \frac{n}{2} \rceil$ ($\frac{n}{2}$ rounded up to the nearest integer) hands, otherwise Alice loses.

Note that in rock-paper-scissors:

  rock beats scissors;  paper beats rock;  scissors beat paper. 

The task is, given the sequence of hands that Bob will play, and the numbers $a, b, c$, determine whether or not Alice can win. And if so, find any possible sequence of hands that Alice can use to win.

If there are multiple answers, print any of them.


-----Input-----

The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases.

Then, $t$ testcases follow, each consisting of three lines:   The first line contains a single integer $n$ ($1 \le n \le 100$).  The second line contains three integers, $a, b, c$ ($0 \le a, b, c \le n$). It is guaranteed that $a + b + c = n$.  The third line contains a string $s$ of length $n$. $s$ is made up of only 'R', 'P', and 'S'. The $i$-th character is 'R' if for his $i$-th Bob plays rock, 'P' if paper, and 'S' if scissors. 


-----Output-----

For each testcase:   If Alice cannot win, print "NO" (without the quotes).  Otherwise, print "YES" (without the quotes). Also, print a string $t$ of length $n$ made up of only 'R', 'P', and 'S' — a sequence of hands that Alice can use to win. $t$ must contain exactly $a$ 'R's, $b$ 'P's, and $c$ 'S's.  If there are multiple answers, print any of them. 

The "YES" / "NO" part of the output is case-insensitive (i.e. "yEs", "no" or "YEs" are all valid answers). Note that 'R', 'P' and 'S' are case-sensitive.


-----Example-----
Input
2
3
1 1 1
RPS
3
3 0 0
RPS

Output
YES
PSR
NO



-----Note-----

In the first testcase, in the first hand, Alice plays paper and Bob plays rock, so Alice beats Bob. In the second hand, Alice plays scissors and Bob plays paper, so Alice beats Bob. In the third hand, Alice plays rock and Bob plays scissors, so Alice beats Bob. Alice beat Bob 3 times, and $3 \ge \lceil \frac{3}{2} \rceil = 2$, so Alice wins.

In the second testcase, the only sequence of hands that Alice can play is "RRR". Alice beats Bob only in the last hand, so Alice can't win. $1 < \lceil \frac{3}{2} \rceil = 2$.

Difficulty: EASY
Tags: Greedy algorithms

Dynamic programming

Constructive algorithms
Skill types: Dynamic programming

Greedy algorithms

Starter code:

Solutions:
import math
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().strip().split()))
	r = arr[0]
	p = arr[1]
	s = arr[2]
	l = []
	win = 0
	string = input()
	for i in string:
		if i == 'R' and p != 0:
			win += 1
			p -= 1
			l.append('P')
		elif i == 'P' and s != 0:
			win += 1
			s -= 1
			l.append('S')
		elif i == 'S' and r != 0:
			win += 1
			r -= 1
			l.append('R')
		else:
			l.append('N')
	if win >= math.ceil(n / 2):
		print('YES')
		for i in l:
			if i == 'R' or i == 'P' or i == 'S':
				print(i, end='')
			elif r != 0:
				print('R', end='')
				r -= 1
			elif p != 0:
				print('P', end='')
				p -= 1
			elif s != 0:
				print('S', end='')
				s -= 1
		print()
	else:
		print('NO')


for testcase in range(int(input())):
	n = int(input())
	(ra, pa, sa) = map(int, input().split())
	beat = {'R': 'P', 'P': 'S', 'S': 'R'}
	a_beat = {'R': pa, 'P': sa, 'S': ra}
	a_sec = []
	win_time = 0
	for i in input().strip():
		if a_beat[i] > 0:
			win_time += 1
			a_beat[i] -= 1
			a_sec.append(beat[i])
		else:
			a_sec.append('.')
	for i in range(n):
		if a_sec[i] != '.':
			continue
		for key in 'RPS':
			if a_beat[key] == 0:
				continue
			a_sec[i] = beat[key]
			a_beat[key] -= 1
			break
	print('YES\n' + ''.join(a_sec) if win_time >= (n + 1) // 2 else 'NO')


for _ in range(int(input())):
	n = int(input())
	l = []
	cnt = 0
	(a, b, c) = map(int, input().split())
	s = input()
	R = a - s.count('S')
	P = b - s.count('R')
	S = c - s.count('P')
	for i in s:
		if i == 'R':
			if b > 0:
				l.append('P')
				b -= 1
				cnt += 1
			elif R > 0:
				l.append('R')
				R -= 1
			else:
				l.append('S')
				S -= 1
		elif i == 'P':
			if c > 0:
				l.append('S')
				c -= 1
				cnt += 1
			elif P > 0:
				l.append('P')
				P -= 1
			else:
				l.append('R')
				R -= 1
		elif i == 'S':
			if a > 0:
				l.append('R')
				a -= 1
				cnt += 1
			elif S > 0:
				l.append('S')
				S -= 1
			else:
				l.append('P')
				P -= 1
	if cnt >= n // 2 + n % 2 and len(l) == n:
		print('YES')
		print(''.join(l))
	else:
		print('NO\n')


from math import ceil
for _ in range(int(input())):
	n = int(input())
	(a, b, c) = [int(i) for i in input().split()]
	w = input()
	s = []
	for i in range(n):
		elem = w[i]
		if elem == 'R' and b > 0:
			s.append('P')
			b -= 1
		elif elem == 'S' and a > 0:
			s.append('R')
			a -= 1
		elif elem == 'P' and c > 0:
			s.append('S')
			c -= 1
		else:
			s.append(0)
	if s.count(0) > n - ceil(n / 2):
		print('NO')
	else:
		print('YES')
		for elem in s:
			if elem != 0:
				print(elem, end='')
			elif elem == 0:
				if a > 0:
					a -= 1
					print('R', end='')
				elif b > 0:
					b -= 1
					print('P', end='')
				else:
					print('S', end='')
		print()


import math
T = int(input())
for t in range(T):
	N = int(input())
	(ra, pa, sa) = map(int, input().split())
	seq = input()
	rb = 0
	pb = 0
	sb = 0
	for n in range(N):
		if seq[n] == 'R':
			rb += 1
		elif seq[n] == 'P':
			pb += 1
		else:
			sb += 1
	win = 0
	out = ['' for n1 in range(N)]
	for n2 in range(N):
		curr = seq[n2]
		if curr == 'R':
			if pa > 0:
				out[n2] = 'P'
				pa -= 1
				win += 1
		elif curr == 'P':
			if sa > 0:
				out[n2] = 'S'
				sa -= 1
				win += 1
		elif ra > 0:
			out[n2] = 'R'
			ra -= 1
			win += 1
	if win >= math.ceil(N / 2):
		print('YES')
		for n3 in range(N):
			if out[n3] == '':
				if pa > 0:
					out[n3] = 'P'
					pa -= 1
				elif sa > 0:
					out[n3] = 'S'
					sa -= 1
				else:
					out[n3] = 'R'
					ra -= 1
		print(''.join(out))
	else:
		print('NO')


q = int(input())
for re in range(q):
	n = int(input())
	(a, b, c) = list(map(int, input().split()))
	st = input()
	odp = [0] * n
	wyn = 0
	for i in range(n):
		if st[i] == 'R' and b > 0:
			wyn += 1
			b -= 1
			odp[i] = 'P'
		if st[i] == 'P' and c > 0:
			wyn += 1
			c -= 1
			odp[i] = 'S'
		if st[i] == 'S' and a > 0:
			wyn += 1
			a -= 1
			odp[i] = 'R'
	for i in range(n):
		if odp[i] == 0:
			if a > 0:
				a -= 1
				odp[i] = 'R'
			elif b > 0:
				b -= 1
				odp[i] = 'P'
			else:
				c -= 1
				odp[i] = 'S'
	if wyn >= (n + 1) // 2:
		print('YES')
		for i in range(n):
			if i < n - 1:
				print(odp[i], end='')
			else:
				print(odp[i])
	else:
		print('NO')


import math
r = int(input())
s2i = {'R': 0, 'P': 1, 'S': 2}
win = {'R': 'P', 'P': 'S', 'S': 'R'}
for _ in range(r):
	n = int(input())
	(a, b, c) = [j for j in map(int, input().split(' '))]
	seq = list(input())
	output = [0] * n
	p = {'R': a, 'P': b, 'S': c}
	wins = 0
	for (i, s) in enumerate(seq):
		if p[win[s]] > 0:
			output[i] = win[s]
			p[win[s]] -= 1
			wins += 2
	for (i, o) in enumerate(output):
		if o == 0:
			for k in p.keys():
				if p[k] > 0:
					output[i] = k
					p[k] -= 1
					break
	print('YES\n' + ''.join(output) if wins >= n else 'NO')


for _ in range(int(input())):
	n = int(input())
	win = n / 2
	if win < n // 2 + 0.5:
		win = n // 2
	else:
		win = n // 2 + 1
	win = int(win)
	(a, b, c) = map(int, input().split())
	s = input()
	l = []
	i = 0
	while i < len(s):
		d = s[i]
		l.append(d)
		i = i + 1
	yo = []
	res = ''
	j = 0
	cnt = 0
	while j < len(l):
		if l[j] == 'R':
			if b != 0:
				yo.append('P')
				b = b - 1
				cnt = cnt + 1
			else:
				yo.append('0')
		elif l[j] == 'P':
			if c != 0:
				yo.append('S')
				c = c - 1
				cnt = cnt + 1
			else:
				yo.append('0')
		elif l[j] == 'S':
			if a != 0:
				yo.append('R')
				a = a - 1
				cnt = cnt + 1
			else:
				yo.append('0')
		j = j + 1
	h = 0
	while h < len(yo):
		r = yo[h]
		if r == '0':
			if a != 0:
				yo[h] = 'R'
				a = a - 1
			elif b != 0:
				yo[h] = 'P'
				b = b - 1
			elif c != 0:
				yo[h] = 'S'
				c = c - 1
		h = h + 1
	for w in yo:
		res = res + w
	if cnt < win:
		print('NO')
	elif cnt >= win:
		print('YES')
		print(res)


for _ in range(int(input())):
	n = int(input())
	(r, p, s) = map(int, input().split())
	b = list(input())
	rx = b.count('R')
	px = b.count('P')
	sx = b.count('S')
	w = 0
	w += min(r, sx)
	w += min(s, px)
	w += min(p, rx)
	if w < (n + 1) // 2:
		print('NO')
	else:
		ans = ['-' for i in range(n)]
		for i in range(n):
			if b[i] == 'R':
				if p > 0:
					p -= 1
					ans[i] = 'P'
			elif b[i] == 'P':
				if s > 0:
					s -= 1
					ans[i] = 'S'
			elif r > 0:
				r -= 1
				ans[i] = 'R'
		for i in range(n):
			if ans[i] == '-':
				if r > 0:
					r -= 1
					ans[i] = 'R'
				elif p > 0:
					p -= 1
					ans[i] = 'P'
				else:
					s -= 1
					ans[i] = 'S'
		print('YES')
		print(''.join(ans))


t = int(input())
for i in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	inp = list(input())
	if n % 2 == 0:
		num = n // 2
	else:
		num = 1 + n // 2
	R = inp.count('R')
	P = inp.count('P')
	S = inp.count('S')
	ans = []
	for j in range(n):
		ans.append('6')
	if min(a, S) + min(b, R) + min(c, P) >= num:
		print('YES')
		coun = 0
		for j in range(n):
			if inp[j] == 'R' and b > 0:
				ans[j] = 'P'
				b -= 1
			elif inp[j] == 'P' and c > 0:
				ans[j] = 'S'
				c -= 1
			elif inp[j] == 'S' and a > 0:
				ans[j] = 'R'
				a -= 1
		for j in range(n):
			if ans[j] == '6':
				if a > 0:
					ans[j] = 'R'
					a -= 1
				elif b > 0:
					ans[j] = 'P'
					b -= 1
				elif c > 0:
					ans[j] = 'S'
					c -= 1
			if j != n - 1:
				print(ans[j], end='')
			else:
				print(ans[j])
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split(' '))
	s = input()
	m = [''] * n
	cnt = 0
	for i in range(n):
		if s[i] == 'R' and b != 0:
			m.pop(i)
			m.insert(i, 'P')
			cnt += 1
			b -= 1
		if s[i] == 'P' and c != 0:
			m.pop(i)
			m.insert(i, 'S')
			cnt += 1
			c -= 1
		if s[i] == 'S' and a != 0:
			m.pop(i)
			m.insert(i, 'R')
			cnt += 1
			a -= 1
	for i in range(n):
		if m[i] == '':
			if a != 0:
				m.pop(i)
				m.insert(i, 'R')
				a -= 1
				continue
			if b != 0:
				m.pop(i)
				m.insert(i, 'P')
				b -= 1
				continue
			if c != 0:
				m.pop(i)
				m.insert(i, 'S')
				c -= 1
				continue
	r = ''.join([li for li in m])
	if cnt >= n / 2:
		print('YES')
		print(r)
	else:
		print('NO')


I = input
X = 'S PR'
for _ in [0] * int(I()):
	n = int(I())
	(a, b, c) = map(int, I().split())
	t = [c, 0, b, a]
	r = [0] * n
	s = i = 0
	for x in input():
		j = ord(x) - 80
		if t[j]:
			s += 1
			r[i] = X[j]
			t[j] -= 1
		i += 1
	for i in range(n):
		if r[i] == 0:
			j = next((j for j in range(4) if t[j]))
			r[i] = X[j]
			t[j] -= 1
	print(*(['YES', ''.join(r)], ['NO'])[2 * s < n])


for _ in range(int(input())):
	cnt = 0
	n = int(input())
	(a, b, c) = [int(x) for x in input().split()]
	l = str(input())
	r = [0] * n
	(a1, b1, c1) = (0, 0, 0)
	for i in range(n):
		if l[i] == 'R':
			if b != 0:
				r[i] = 'P'
				b -= 1
		if l[i] == 'P':
			if c != 0:
				r[i] = 'S'
				c -= 1
		if l[i] == 'S':
			if a != 0:
				r[i] = 'R'
				a -= 1
	if n - (a + b + c) >= n / 2:
		for j in range(n):
			if r[j] == 0:
				if a != 0:
					r[j] = 'R'
					a -= 1
					continue
				if b != 0:
					r[j] = 'P'
					b -= 1
					continue
				if c != 0:
					r[j] = 'S'
					c -= 1
					continue
		print('YES')
		print(''.join(map(str, r)))
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	(a, b, c) = map(int, input().split())
	assert a + b + c == n, 'Invalid a b c'
	s = input()
	assert len(s) == n, 'Invalid length of s'
	ans = ''
	for ch in s:
		if ch == 'R' and b:
			b -= 1
			ans += 'P'
		elif ch == 'P' and c:
			c -= 1
			ans += 'S'
		elif ch == 'S' and a:
			a -= 1
			ans += 'R'
		else:
			ans += '0'
	win = n - ans.count('0')
	assert len(ans) == n
	assert ans.count('0') == a + b + c
	assert a + b + c == n - win
	if 2 * win >= n:
		print('YES')
		for i in range(n):
			if ans[i] == '0':
				if a:
					print('R', end='')
					a -= 1
				elif b:
					print('P', end='')
					b -= 1
				elif c:
					print('S', end='')
					c -= 1
			else:
				print(ans[i], end='')
		print()
	else:
		print('NO')


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	(a, b, c) = map(int, input().split())
	k = input()
	k = list(k)
	if n % 2 == 0:
		x = int(n / 2)
	else:
		x = int(n / 2) + 1
	s = list()
	for i in range(n):
		s.append('0')
	abc = 0
	for i in range(len(k)):
		if k[i] == 'R':
			if b > 0:
				s[i] = 'P'
				b -= 1
				x -= 1
		elif k[i] == 'P':
			if c > 0:
				s[i] = 'S'
				c -= 1
				x -= 1
		elif k[i] == 'S':
			if a > 0:
				s[i] = 'R'
				a -= 1
				x -= 1
	for i in range(n):
		if a > 0 and s[i] == '0':
			s[i] = 'R'
			a -= 1
		if b > 0 and s[i] == '0':
			s[i] = 'P'
			b -= 1
		if c > 0 and s[i] == '0':
			s[i] = 'S'
			c -= 1
	if x <= 0:
		print('YES')
		print(''.join(s))
	elif x > 0:
		print('NO')


import math
t = int(input())
for tt in range(t):
	n = int(input())
	(r, p, s) = map(int, input().split())
	wins = 0
	move = input()
	alice = ['0'] * n
	for i in range(n):
		if move[i] == 'R':
			if p > 0:
				wins += 1
				p -= 1
				alice[i] = 'P'
		elif move[i] == 'S':
			if r > 0:
				wins += 1
				r -= 1
				alice[i] = 'R'
		elif move[i] == 'P':
			if s > 0:
				wins += 1
				alice[i] = 'S'
				s -= 1
	for i in range(n):
		if alice[i] == '0':
			if p > 0:
				alice[i] = 'P'
				p -= 1
			elif r > 0:
				alice[i] = 'R'
				r -= 1
			elif s > 0:
				alice[i] = 'S'
				s -= 1
	if math.ceil(n / 2) <= wins:
		print('YES')
		ans = ''.join(alice)
		print(ans)
	else:
		print('NO')


import math
t = int(input())
for _ in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	hand = list(map(str, list(input())))
	seq = []
	d = {'R': 'P', 'P': 'S', 'S': 'R'}
	total = {'R': a, 'P': b, 'S': c}
	r = hand.count('R')
	p = hand.count('P')
	s = hand.count('S')
	score = min(a, s) + min(b, r) + min(c, p)
	if score >= math.ceil(n / 2):
		print('YES')
		for i in hand:
			play = d[i]
			if total[play] > 0:
				seq.append(play)
				total[play] -= 1
			else:
				seq.append('Z')
		for i in range(n):
			if seq[i] == 'Z':
				for key in total:
					if total[key] > 0:
						seq[i] = key
						total[key] -= 1
						break
		print(''.join(seq))
	else:
		print('NO')


import sys, os, io
from math import gcd
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	(a, b, c) = [int(i) for i in input().split()]
	s = input().strip()
	ans = []
	win = 0
	a1 = s.count('R')
	b1 = s.count('P')
	c1 = s.count('S')
	wins = min(b, a1) + min(c, b1) + min(a, c1)
	m = n // 2
	if n % 2:
		m += 1
	if wins >= m:
		print('YES')
		ans = ['?'] * n
		j = min(b, a1)
		for i in range(n):
			if j == 0:
				break
			if s[i] == 'R':
				ans[i] = 'P'
				j -= 1
				b -= 1
		j = min(c, b1)
		for i in range(n):
			if j == 0:
				break
			if s[i] == 'P':
				ans[i] = 'S'
				j -= 1
				c -= 1
		j = min(a, c1)
		for i in range(n):
			if j == 0:
				break
			if s[i] == 'S':
				ans[i] = 'R'
				j -= 1
				a -= 1
		for i in range(n):
			if ans[i] == '?':
				if a > 0:
					ans[i] = 'R'
					a -= 1
				elif b > 0:
					ans[i] = 'P'
					b -= 1
				else:
					ans[i] = 'S'
					c -= 1
		for i in ans:
			print(i, end='')
		print()
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	S = input()
	(a2, b2, c2) = (S.count('R'), S.count('P'), S.count('S'))
	win = min(a, c2) + min(b, a2) + min(c, b2)
	if win >= (n + 1) // 2:
		print('YES')
		ans = [-1] * n
		for i in range(n):
			if S[i] == 'R':
				if b > 0:
					ans[i] = 'P'
					b -= 1
			elif S[i] == 'P':
				if c > 0:
					ans[i] = 'S'
					c -= 1
			elif S[i] == 'S':
				if a > 0:
					ans[i] = 'R'
					a -= 1
		amari = ['R'] * a + ['P'] * b + ['S'] * c
		counter = 0
		for i in range(n):
			if ans[i] == -1:
				ans[i] = amari[counter]
				counter += 1
		print(''.join(ans))
	else:
		print('NO')


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for pp in range(t):
		solve(pp)

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def google(p):
	print('Case #' + str(p) + ': ', end='')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve(case):
	n = int(inp())
	(a, b, c) = sep()
	seq = inp()
	ans = [0] * n
	cnt = {'S': 0, 'R': 0, 'P': 0}
	for i in range(n):
		if seq[i] not in cnt:
			cnt[seq[i]] = 1
		else:
			cnt[seq[i]] += 1
	wins = [0, 0, 0]
	wins[0] = min(a, cnt['S'])
	wins[1] = min(b, cnt['R'])
	wins[2] = min(c, cnt['P'])
	temp = deepcopy(wins)
	if sum(temp) < ceil(n / 2):
		print('NO')
		return
	have = ['R', 'P', 'S']
	to = ['S', 'R', 'P']
	for i in range(3):
		for j in range(n):
			if temp[i] == 0:
				break
			if seq[j] == to[i]:
				ans[j] = have[i]
				temp[i] -= 1
	a -= wins[0]
	b -= wins[1]
	c -= wins[2]
	for i in range(n):
		if a == 0 and b == 0 and (c == 0):
			break
		if ans[i] == 0:
			if a != 0:
				ans[i] = 'R'
				a -= 1
				continue
			if b != 0:
				ans[i] = 'P'
				b -= 1
				continue
			if c != 0:
				ans[i] = 'S'
				c -= 1
				continue
	print('YES')
	print(''.join(ans))
testcase(int(inp()))


from math import *
for i in range(int(input())):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s1 = input()
	if len(s1) > n:
		print('NO')
	else:
		r = s1.count('R')
		p = s1.count('P')
		s = s1.count('S')
		if r == b and p == c and (s == a):
			print('YES')
			for j in range(len(s1)):
				if s1[j] == 'R':
					print('P', end='')
				elif s1[j] == 'P':
					print('S', end='')
				else:
					print('R', end='')
			print()
		else:
			rslt = min(r, b) + min(p, c) + min(s, a)
			if ceil(n / 2) <= rslt:
				print('YES')
				ans = [0] * len(s1)
				for i in range(len(s1)):
					if s1[i] == 'R' and b > 0:
						ans[i] = 'P'
						b -= 1
					elif s1[i] == 'P' and c > 0:
						ans[i] = 'S'
						c -= 1
					elif s1[i] == 'S' and a > 0:
						ans[i] = 'R'
						a -= 1
				for i in range(len(ans)):
					if ans[i] == 0:
						if a > 0:
							ans[i] = 'R'
							a -= 1
						elif b > 0:
							ans[i] = 'P'
							b -= 1
						elif c > 0:
							ans[i] = 'S'
							c -= 1
				print(''.join(ans))
			else:
				print('NO')


import collections
for t in range(int(input())):
	n = int(input())
	(r, p, s) = list(map(int, input().split()))
	b = input()
	(S, P, R) = (b.count('S'), b.count('P'), b.count('R'))
	cnt = 0
	ans = ''
	for i in range(n):
		if b[i] == 'S':
			if r > 0:
				(ans, r, cnt) = (ans + 'R', r - 1, cnt + 1)
			else:
				if p > R:
					(ans, p) = (ans + 'P', p - 1)
				if len(ans) < i + 1 and s > P:
					(ans, s) = (ans + 'S', s - 1)
			S -= 1
		elif b[i] == 'P':
			if s > 0:
				(ans, s, cnt) = (ans + 'S', s - 1, cnt + 1)
			else:
				if p > R:
					(ans, p) = (ans + 'P', p - 1)
				if len(ans) < i + 1 and r > S:
					(ans, r) = (ans + 'R', r - 1)
			P -= 1
		else:
			if p > 0:
				(ans, p, cnt) = (ans + 'P', p - 1, cnt + 1)
			else:
				if s > P:
					(ans, s) = (ans + 'S', s - 1)
				if len(ans) < i + 1 and r > S:
					(ans, r) = (ans + 'R', r - 1)
			R -= 1
	if cnt < n // 2 + n % 2:
		print('NO')
	else:
		print('YES')
		print(ans)


for _ in range(int(input())):
	n = int(input())
	(a, b, c) = map(int, input().split())
	game = input()
	R = []
	P = []
	S = []
	for i in range(n):
		if game[i] == 'R':
			R.append(i)
		elif game[i] == 'P':
			P.append(i)
		else:
			S.append(i)
	A_a = min(len(S), a)
	a -= A_a
	A_b = min(len(R), b)
	b -= A_b
	A_c = min(len(P), c)
	c -= A_c
	if A_a + A_b + A_c >= (n + 1) // 2:
		print('YES')
		ans = [None] * n
		for i in range(A_a):
			ans[S[i]] = 'R'
		for i in range(A_b):
			ans[R[i]] = 'P'
		for i in range(A_c):
			ans[P[i]] = 'S'
		for i in range(n):
			if ans[i] == None:
				if a > 0:
					ans[i] = 'R'
					a -= 1
				elif b > 0:
					ans[i] = 'P'
					b -= 1
				elif c > 0:
					ans[i] = 'S'
					c -= 1
		print(''.join(ans))
	else:
		print('NO')


from math import ceil
for _ in range(int(input())):
	n = int(input())
	(a, b, c) = map(int, input().split())
	(x, y, z) = (a, b, c)
	s = input()
	count = 0
	arr = [None] * n
	for i in range(n):
		if s[i] == 'R':
			if y > 0:
				y -= 1
				count += 1
				arr[i] = 'P'
		elif s[i] == 'P':
			if z > 0:
				z -= 1
				count += 1
				arr[i] = 'S'
		elif x > 0:
			x -= 1
			count += 1
			arr[i] = 'R'
	if count < ceil(n / 2):
		print('NO')
	else:
		result = ''
		for i in range(n):
			if arr[i] != None:
				result += arr[i]
			elif x > 0:
				result += 'R'
				x -= 1
			elif y > 0:
				result += 'P'
				y -= 1
			else:
				result += 'S'
				z -= 1
		print('YES')
		print(result)


t = int(input())
for i in range(t):
	n = int(input())
	(a, b, c) = (int(i) for i in input().split())
	s = input()
	(aa, bb, cc) = (0, 0, 0)
	for i in s:
		if i == 'R':
			aa += 1
		elif i == 'P':
			bb += 1
		else:
			cc += 1
	ar = min(a, cc)
	br = min(b, aa)
	cr = min(c, bb)
	if ar + br + cr < n // 2 + n % 2:
		print('NO')
	else:
		L = []
		for i in s:
			if i == 'R':
				if b:
					L.append('P')
					b -= 1
					br -= 1
				elif a > ar:
					L.append('R')
					a -= 1
				else:
					L.append('S')
					c -= 1
			if i == 'P':
				if c:
					L.append('S')
					c -= 1
					cr -= 1
				elif a > ar:
					L.append('R')
					a -= 1
				else:
					L.append('P')
					b -= 1
			if i == 'S':
				if a:
					L.append('R')
					a -= 1
					ar -= 1
				elif b > br:
					L.append('P')
					b -= 1
				else:
					L.append('S')
					c -= 1
		print('YES')
		for i in range(n):
			print(L[i], end='')
		print('')


t = int(input())
for j in range(0, t):
	n = int(input())
	l1 = [int(x) for x in input().split()]
	r = l1[0]
	p = l1[1]
	s = l1[2]
	inp = input()
	count_win = 0
	ans = ['' for i in range(0, n)]
	count_r = 0
	count_p = 0
	count_s = 0
	for i in range(0, n):
		if inp[i] == 'R':
			count_r += 1
		elif inp[i] == 'P':
			count_p += 1
		else:
			count_s += 1
	val1 = min(count_r, p)
	val2 = min(count_p, s)
	val3 = min(count_s, r)
	ind = 0
	c = 0
	while ind < n and c < min(count_r, p):
		if inp[ind] == 'R':
			ans[ind] = 'P'
			c += 1
		ind += 1
	ind = 0
	c = 0
	while ind < n and c < min(count_p, s):
		if inp[ind] == 'P':
			ans[ind] = 'S'
			c += 1
		ind += 1
	ind = 0
	c = 0
	while ind < n and c < min(count_s, r):
		if inp[ind] == 'S':
			ans[ind] = 'R'
			c += 1
		ind += 1
	r = r - min(count_s, r)
	p = p - min(count_r, p)
	s = s - min(count_p, s)
	for i in range(0, n):
		if ans[i] == '' and r > 0:
			ans[i] = 'R'
			r -= 1
		elif ans[i] == '' and p > 0:
			ans[i] = 'P'
			p -= 1
		elif ans[i] == '' and s > 0:
			ans[i] = 'S'
			s -= 1
	if n % 2 == 0:
		if val1 + val2 + val3 >= n // 2:
			print('YES')
			print(''.join(ans))
		else:
			print('NO')
	elif val1 + val2 + val3 >= n // 2 + 1:
		print('YES')
		print(''.join(ans))
	else:
		print('NO')


from math import *
t = int(input())
rA = []
for z in range(t):
	n = int(input())
	(a, b, c) = [int(i) for i in input().split()]
	bob = [i for i in input()]
	(cr, rp, cs) = (0, 0, 0)
	cr = bob.count('R')
	cp = bob.count('P')
	cs = bob.count('S')
	dR = b - cr
	dP = c - cp
	dS = a - cs
	s = 0
	rP = ''
	for t in bob:
		if t == 'R' and b > 0:
			b -= 1
			s += 1
			rP += 'P'
		elif t == 'P' and c > 0:
			c -= 1
			s += 1
			rP += 'S'
		elif t == 'S' and a > 0:
			a -= 1
			s += 1
			rP += 'R'
		elif dR > 0:
			rP += 'P'
			dR -= 1
		elif dP > 0:
			rP += 'S'
			dP -= 1
		elif dS > 0:
			rP += 'R'
			dS -= 1
	if s >= ceil(n / 2):
		rA.append('YES')
		rA.append(rP)
	else:
		rA.append('NO')
for i in rA:
	print(i)


import sys
t = int(sys.stdin.readline())
for i in range(t):
	n = int(sys.stdin.readline())
	(a, b, c) = list(map(int, sys.stdin.readline().strip().split()))
	x = list(sys.stdin.readline())
	op = [' '] * n
	if n % 2 == 0:
		w = n // 2
	else:
		w = n // 2 + 1
	z = 0
	for j in range(n):
		if x[j] == 'R':
			if b > 0:
				b -= 1
				z += 1
				op[j] = 'P'
		elif x[j] == 'S':
			if a > 0:
				a -= 1
				z += 1
				op[j] = 'R'
		elif x[j] == 'P':
			if c > 0:
				c -= 1
				z += 1
				op[j] = 'S'
	for j in range(n):
		if op[j] == ' ':
			if a > 0:
				a -= 1
				op[j] = 'R'
			elif b > 0:
				op[j] = 'P'
				b -= 1
			elif c > 0:
				op[j] = 'S'
				c -= 1
	if z >= w:
		print('YES')
		print(''.join(op))
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	(r, p, s) = map(int, input().split())
	l = input()
	h = [None] * n
	(a, b, c) = (l.count('R'), l.count('P'), l.count('S'))
	for i in range(n):
		if l[i] == 'S' and r != 0:
			a -= 1
			r -= 1
			h[i] = 'R'
		elif l[i] == 'P' and s != 0:
			c -= 1
			s -= 1
			h[i] = 'S'
		elif l[i] == 'R' and p != 0:
			b -= 1
			p -= 1
			h[i] = 'P'
	for i in range(n):
		if h[i] is None:
			if r != 0:
				h[i] = 'R'
				r -= 1
			elif p != 0:
				h[i] = 'P'
				p -= 1
			else:
				h[i] = 'S'
				s -= 1
	d = n - a - b - c
	ans = ''.join(h)
	import math
	if d >= math.ceil(n / 2):
		print('YES')
		print(ans)
	else:
		print('NO')


q = int(input())
for queries in range(q):
	n = int(input())
	(a, b, c) = list(map(int, input().split()))
	s = input()
	req = (n + 1) // 2
	s2 = []
	for i in s:
		if i == 'R':
			if b > 0:
				s2 += ['P']
				req -= 1
				b -= 1
			else:
				s2 += ['2']
		if i == 'P':
			if c > 0:
				s2 += ['S']
				req -= 1
				c -= 1
			else:
				s2 += ['3']
		if i == 'S':
			if a > 0:
				s2 += ['R']
				req -= 1
				a -= 1
			else:
				s2 += ['1']
	if req > 0:
		print('NO')
	else:
		print('YES')
		for i in range(n):
			if s2[i] == '1':
				if b > 0:
					b -= 1
					s2[i] = 'P'
				elif c > 0:
					c -= 1
					s2[i] = 'S'
			if s2[i] == '2':
				if a > 0:
					a -= 1
					s2[i] = 'R'
				elif c > 0:
					c -= 1
					s2[i] = 'S'
			if s2[i] == '3':
				if b > 0:
					b -= 1
					s2[i] = 'P'
				elif a > 0:
					a -= 1
					s2[i] = 'R'
		print(''.join(s2))


from collections import Counter
t = int(input())
for _ in range(t):
	n = int(input())
	(a, b, c) = list(map(int, input().split()))
	s = input()
	dic = Counter(s)
	a_ = dic['R']
	b_ = dic['P']
	c_ = dic['S']
	wins = min(a_, b) + min(b_, c) + min(c_, a)
	if wins >= n // 2 + n % 2:
		lst = [0] * n
		for i in range(n):
			if s[i] == 'R' and b > 0:
				lst[i] = 'P'
				b = b - 1
			elif s[i] == 'P' and c > 0:
				lst[i] = 'S'
				c = c - 1
			elif s[i] == 'S' and a > 0:
				lst[i] = 'R'
				a = a - 1
		for i in range(n):
			if lst[i] == 0:
				if a > 0:
					lst[i] = 'R'
					a = a - 1
				elif b > 0:
					lst[i] = 'P'
					b = b - 1
				else:
					lst[i] = 'S'
		print('YES')
		print(''.join(lst))
	else:
		print('NO')


from collections import Counter
import math
t = int(input())
while t > 0:
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	di = Counter(s)
	poss_wins_for_alice = min(di['R'], b) + min(di['S'], a) + min(di['P'], c)
	min_req_wins = math.ceil(n / 2)
	if poss_wins_for_alice >= min_req_wins:
		print('YES')
		arr = ['0' for i in range(n)]
		a_count = 0
		b_count = 0
		c_count = 0
		for i in range(0, n):
			if s[i] == 'P' and c_count < c:
				arr[i] = 'S'
				c_count += 1
			elif s[i] == 'R' and b_count < b:
				arr[i] = 'P'
				b_count += 1
			elif s[i] == 'S' and a_count < a:
				arr[i] = 'R'
				a_count += 1
		curr_pos = 0
		while a_count != a and curr_pos < n:
			if arr[curr_pos] == '0':
				arr[curr_pos] = 'R'
				a_count += 1
			curr_pos += 1
		while b_count != b and curr_pos < n:
			if arr[curr_pos] == '0':
				arr[curr_pos] = 'P'
				b_count += 1
			curr_pos += 1
		while c_count != c and curr_pos < n:
			if arr[curr_pos] == '0':
				arr[curr_pos] = 'S'
				c_count += 1
			curr_pos += 1
		st = ''
		for i in range(0, len(arr)):
			st = st + arr[i]
		print(st)
	else:
		print('NO')
	t -= 1


import math
t = int(input())
for tt in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input().strip()
	ans = [None] * len(s)
	cc = 0
	for i in range(n):
		if s[i] == 'S' and a > 0:
			a -= 1
			ans[i] = 'R'
			cc += 1
		if s[i] == 'R' and b > 0:
			b -= 1
			ans[i] = 'P'
			cc += 1
		if s[i] == 'P' and c > 0:
			c -= 1
			ans[i] = 'S'
			cc += 1
	lol = math.ceil(n / 2)
	if cc < lol:
		print('NO')
	else:
		for i in range(len(s)):
			if ans[i] != None:
				continue
			if a > 0:
				ans[i] = 'R'
				a -= 1
			elif b > 0:
				ans[i] = 'P'
				b -= 1
			elif c > 0:
				ans[i] = 'S'
				c -= 1
		print('YES')
		print(''.join(ans))


import math
t = int(input())
for _ in range(t):
	n = int(input())
	(r, p, s) = map(int, input().split())
	Bob = input()
	br = Bob.count('R')
	bp = Bob.count('P')
	bs = Bob.count('S')
	total = 0
	total += min(r, bs) + min(p, br) + min(s, bp)
	ans = [' ' for i in range(n)]
	for i in range(n):
		if Bob[i] == 'R' and p != 0:
			ans[i] = 'P'
			p -= 1
		elif Bob[i] == 'S' and r != 0:
			ans[i] = 'R'
			r -= 1
		elif Bob[i] == 'P' and s != 0:
			ans[i] = 'S'
			s -= 1
	for i in range(n):
		if ans[i] == ' ':
			if p > 0:
				ans[i] = 'P'
				p -= 1
			elif r > 0:
				ans[i] = 'R'
				r -= 1
			elif s > 0:
				ans[i] = 'S'
				s -= 1
	if total >= math.ceil(n / 2):
		print('YES')
		print(''.join(ans))
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input().strip()
	f = {}
	for i in s:
		f[i] = (f.get(i) or 0) + 1
	a1 = f.get('R') or 0
	b1 = f.get('P') or 0
	c1 = f.get('S') or 0
	lost = max(0, a1 - b) + max(0, b1 - c) + max(0, c1 - a)
	won = n - lost
	if won >= n / 2:
		print('YES')
		moves = []
		for i in s:
			if i == 'R' and b > 0:
				moves.append('P')
				b -= 1
			elif i == 'P' and c > 0:
				moves.append('S')
				c -= 1
			elif i == 'S' and a > 0:
				moves.append('R')
				a -= 1
			else:
				moves.append(None)
		for i in range(n):
			if moves[i] is None:
				if a > 0:
					moves[i] = 'R'
					a -= 1
				elif b > 0:
					moves[i] = 'P'
					b -= 1
				else:
					moves[i] = 'S'
					c -= 1
		moves = ''.join(moves)
		print(moves)
	else:
		print('NO')


import math
t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	(a, b, c) = map(int, input().split())
	ar = list(input())
	(r, p, s) = (0, 0, 0)
	for i in ar:
		if i == 'R':
			r += 1
		elif i == 'P':
			p += 1
		else:
			s += 1
	if min(a, s) + min(b, r) + min(c, p) < math.ceil(n / 2):
		print('NO')
		continue
	br = ['x' for _ in range(n)]
	for i in range(n):
		if ar[i] == 'R':
			if b > 0:
				br[i] = 'P'
				b -= 1
		elif ar[i] == 'P':
			if c > 0:
				br[i] = 'S'
				c -= 1
		elif ar[i] == 'S':
			if a > 0:
				br[i] = 'R'
				a -= 1
	for i in range(n):
		if br[i] == 'x':
			if a > 0:
				br[i] = 'R'
				a -= 1
			elif b > 0:
				br[i] = 'P'
				b -= 1
			elif c > 0:
				br[i] = 'S'
				c -= 1
	print('YES')
	print(''.join(br))


import re, math, decimal, bisect

def read():
	return input().strip()

def iread():
	return int(input().strip())

def viread():
	return [int(_) for _ in input().strip().split()]
for i in range(iread()):
	n = iread()
	(r1, p1, s1) = viread()
	hands = read()
	(r2, p2, s2) = (hands.count('R'), hands.count('P'), hands.count('S'))
	if min(r2, p1) + min(p2, s1) + min(s2, r1) >= math.ceil(n / 2):
		print('YES')
		burn = 'r' * (r1 - min(s2, r1)) + 'p' * (p1 - min(r2, p1)) + 's' * (s1 - min(p2, s1))
		burn = list(burn)
		ans = hands.replace('R', 'p', min(r2, p1)).replace('P', 's', min(p2, s1)).replace('S', 'r', min(s2, r1))
		for c in ans:
			if c < 'a':
				print(burn.pop().upper(), end='')
			else:
				print(c.upper(), end='')
		print()
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	(a, b, c) = list(map(int, input().split()))
	d = list(input())
	ans = 0
	ansarr = ['0' for x in range(n)]
	ansstr = ''
	for j in range(n):
		if d[j] == 'R' and b > 0:
			b -= 1
			ans += 1
			ansarr[j] = 'P'
		elif d[j] == 'P' and c > 0:
			c -= 1
			ans += 1
			ansarr[j] = 'S'
		elif d[j] == 'S' and a > 0:
			a -= 1
			ans += 1
			ansarr[j] = 'R'
	for j in range(n):
		if ansarr[j] == '0':
			if a > 0:
				a -= 1
				ansstr += 'R'
			elif b > 0:
				b -= 1
				ansstr += 'P'
			else:
				c -= 1
				ansstr += 'S'
		else:
			ansstr += ansarr[j]
	if ans >= n / 2:
		print('YES')
		print(ansstr)
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split(' '))
	(r, p, s) = (0, 0, 0)
	string = input()
	for j in string:
		if j == 'R':
			r += 1
		if j == 'P':
			p += 1
		if j == 'S':
			s += 1
	res = min(a, s) + min(b, r) + min(c, p)
	if res < n / 2:
		print('NO')
	else:
		print('YES')
		result = ''
		for j in string:
			if j == 'R':
				if b > 0:
					result += 'P'
					b -= 1
				else:
					result += '.'
			if j == 'P':
				if c > 0:
					result += 'S'
					c -= 1
				else:
					result += '.'
			if j == 'S':
				if a > 0:
					result += 'R'
					a -= 1
				else:
					result += '.'
		list_res = list(result)
		for j in range(0, len(list_res)):
			if list_res[j] == '.':
				if a > 0:
					list_res[j] = 'R'
					a -= 1
				elif b > 0:
					list_res[j] = 'P'
					b -= 1
				else:
					list_res[j] = 'S'
					c -= 1
		for j in list_res:
			print(j, end='')
		print()


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	(a, b, c) = map(int, input().rstrip().split())
	s = input()
	li = ['X'] * n
	pts = 0
	for i in range(n):
		if s[i] == 'R' and b > 0:
			li[i] = 'P'
			pts += 1
			b -= 1
		elif s[i] == 'P' and c > 0:
			li[i] = 'S'
			c -= 1
			pts += 1
		elif s[i] == 'S' and a > 0:
			li[i] = 'R'
			a -= 1
			pts += 1
	if pts < n / 2:
		print('NO')
	else:
		print('YES')
		for i in range(n):
			if li[i] == 'X':
				if a > 0:
					li[i] = 'R'
					a -= 1
				elif b > 0:
					li[i] = 'P'
					b -= 1
				elif c > 0:
					li[i] = 'S'
					c -= 1
		print(''.join(li))


t = int(input())
while t:
	t -= 1
	n = int(input())
	(a, b, c) = [int(x) for x in input().split()]
	str = input()
	ans = ''
	cnt = 0
	for i in str:
		if i == 'R' and b:
			b -= 1
			ans += 'P'
			cnt += 1
		elif i == 'S' and a:
			a -= 1
			ans += 'R'
			cnt += 1
		elif i == 'P' and c:
			c -= 1
			ans += 'S'
			cnt += 1
		else:
			ans += ' '
	out = ''
	for i in ans:
		if i != ' ':
			out += i
		elif a:
			a -= 1
			out += 'R'
		elif b:
			b -= 1
			out += 'P'
		else:
			c -= 1
			out += 'S'
	if (n + 1) // 2 <= cnt:
		print('YES')
		print(out)
	else:
		print('NO')


def comp(s, a, b, c):
	if s == 'R' and b > 0:
		b -= 1
		return 'P'
	if s == 'P' and c > 0:
		c -= 1
		return 'S'
	if s == 'S' and a > 0:
		a -= 1
		return 'R'
	return -1
for tc in [0] * int(input()):
	n = int(input())
	(a, b, c) = map(int, input().split())
	o = input()
	k = list(o)
	r = o.replace('R', 'P', b)
	p = o.replace('P', 'S', c)
	si = o.replace('S', 'R', a)
	an = n
	for i in range(n):
		s = o[i]
		if s == 'R' and b > 0:
			b -= 1
			k[i] = 'P'
		elif s == 'P' and c > 0:
			c -= 1
			k[i] = 'S'
		elif s == 'S' and a > 0:
			a -= 1
			k[i] = 'R'
		else:
			an -= 1
			k[i] = 'l'
	for i in range(n):
		if k[i] == 'l':
			if b > 0:
				b -= 1
				k[i] = 'P'
			elif c > 0:
				c -= 1
				k[i] = 'S'
			elif a > 0:
				a -= 1
				k[i] = 'R'
	if an >= (n + 1) // 2:
		print('YES\n' + ''.join(k))
	else:
		print('NO')


t = int(input())
answer = []
for i in range(t):
	n = int(input())
	(a, b, c) = list(map(int, input().split()))
	string = str(input())
	a1 = 0
	b1 = 0
	c1 = 0
	for j in range(n):
		if string[j] == 'S':
			a1 += 1
		elif string[j] == 'R':
			b1 += 1
		else:
			c1 += 1
	win = min(a, a1) + min(b, b1) + min(c, c1)
	if n % 2 == 1:
		k = n // 2 + 1
	else:
		k = int(n / 2)
	if win >= k:
		answer.append(['YES'])
		j = 0
		ans = ['A'] * n
		while a > 0 and j < n:
			if string[j] == 'S':
				ans[j] = 'R'
				a -= 1
			j += 1
		j = 0
		while b > 0 and j < n:
			if string[j] == 'R':
				ans[j] = 'P'
				b -= 1
			j += 1
		j = 0
		while c > 0 and j < n:
			if string[j] == 'P':
				ans[j] = 'S'
				c -= 1
			j += 1
		j = 0
		while a > 0 and j < n:
			if ans[j] == 'A':
				ans[j] = 'R'
				a -= 1
			j += 1
		while b > 0 and j < n:
			if ans[j] == 'A':
				ans[j] = 'P'
				b -= 1
			j += 1
		while c > 0 and j < n:
			if ans[j] == 'A':
				ans[j] = 'S'
				c -= 1
			j += 1
		answer.append(ans)
	else:
		answer.append(['NO'])
for i in range(len(answer)):
	print(*answer[i], sep='')


import os
import sys
from io import BytesIO, IOBase
from collections import Counter, defaultdict
from math import ceil

def solution(s, n, a, b, c):
	win = {'R': 'P', 'S': 'R', 'P': 'S'}
	counts = Counter(s)
	(res, wins) = (defaultdict(list), 0)
	if a >= 1 and counts['S'] >= 1:
		wins += min(a, counts['S'])
		res['S'] = ['R'] * min(a, counts['S'])
		if a >= counts['S']:
			a -= counts['S']
		else:
			a = 0
	if b >= 1 and counts['R'] >= 1:
		wins += min(b, counts['R'])
		res['R'] = ['P'] * min(b, counts['R'])
		if b >= counts['R']:
			b -= counts['R']
		else:
			b = 0
	if c >= 1 and counts['P'] >= 1:
		wins += min(c, counts['P'])
		res['P'] = ['S'] * min(c, counts['P'])
		if c >= counts['P']:
			c -= counts['P']
		else:
			c = 0
	leftover = ['R'] * a + ['P'] * b + ['S'] * c
	if wins >= ceil(n / 2):
		final = []
		for c in s:
			if res[c]:
				final.append(res[c].pop())
			else:
				final.append(leftover.pop())
		write('YES')
		write(''.join(final))
	else:
		write('NO')

def main():
	for _ in range(r_int()):
		n = r_int()
		(a, b, c) = r_array()
		s = list(input())
		solution(s, n, a, b, c)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def write(*args, end='\n'):
	for x in args[:-1]:
		sys.stdout.write(str(x) + ' ')
	sys.stdout.write(str(args[-1]))
	sys.stdout.write(end)

def r_array():
	return [int(x) for x in input().split()]

def r_int():
	return int(input())
main()


from math import *
for u in range(int(input())):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	r = ['X'] * n
	(x, y) = (0, 0)
	for i in range(n):
		if s[i] == 'P' and c:
			c = c - 1
			r[i] = 'S'
			x = x + 1
		elif s[i] == 'R' and b:
			b = b - 1
			r[i] = 'P'
			x = x + 1
		elif s[i] == 'S' and a:
			a = a - 1
			r[i] = 'R'
			x = x + 1
	if x < ceil(n / 2):
		print('NO')
	else:
		print('YES')
		for i in range(n):
			if r[i] == 'X':
				if a:
					a = a - 1
					r[i] = 'R'
				elif b:
					b = b - 1
					r[i] = 'P'
				elif c:
					c = c - 1
					r[i] = 'S'
		print(''.join(r))


import math
tests = int(input())
for test in range(tests):
	n = int(input())
	(a, b, c) = list(map(int, input().split()))
	string = list(input())
	result = []
	ok = False
	count = 0
	for i in range(n):
		el = string[i]
		if el == 'R' and b > 0:
			result.append('P')
			count += 1
			b -= 1
		elif el == 'P' and c > 0:
			result.append('S')
			count += 1
			c -= 1
		elif el == 'S' and a > 0:
			result.append('R')
			count += 1
			a -= 1
		else:
			result.append('v')
	for i in range(n):
		if result[i] == 'v':
			if b > 0:
				result[i] = 'P'
				b -= 1
			elif a > 0:
				result[i] = 'R'
				a -= 1
			elif c > 0:
				result[i] = 'S'
				c -= 1
	if count >= math.ceil(n / 2):
		print('YES')
		print(''.join(result))
	else:
		print('NO')


import math
t = int(input())
for nt in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	k = input()
	ans = ''
	for i in k:
		if i == 'R':
			ans += 'P'
		elif i == 'P':
			ans += 'S'
		else:
			ans += 'R'
	r = ans.count('R')
	p = ans.count('P')
	s = ans.count('S')
	if min(a, r) + min(p, b) + min(s, c) >= math.ceil(n / 2):
		print('YES')
		counta = 0
		countb = 0
		countc = 0
		ans = [''] * n
		for i in range(n):
			if k[i] == 'P':
				if countc != c:
					ans[i] = 'S'
					countc += 1
			elif k[i] == 'R':
				if countb != b:
					ans[i] = 'P'
					countb += 1
			elif k[i] == 'S':
				if counta != a:
					ans[i] = 'R'
					counta += 1
		for i in range(n):
			if ans[i] == '':
				if counta != a:
					ans[i] += 'R'
					counta += 1
				elif countb != b:
					ans[i] += 'P'
					countb += 1
				elif countc != c:
					ans[i] += 'S'
					countc += 1
		for i in ans:
			print(i, end='')
		print()
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	ll = list(map(int, input().split()))
	s = input()
	ans = ['-' for _ in range(n)]
	d = {0: 'R', 1: 'P', 2: 'S'}
	k = 0
	for i in range(n):
		if s[i] == 'R' and ll[1] > 0:
			ans[i] = 'P'
			ll[1] -= 1
			k += 1
		if s[i] == 'P' and ll[2] > 0:
			ans[i] = 'S'
			ll[2] -= 1
			k += 1
		if s[i] == 'S' and ll[0] > 0:
			ans[i] = 'R'
			ll[0] -= 1
			k += 1
	if k >= (n + 1) // 2:
		for i in range(n):
			if ans[i] == '-':
				for j in range(3):
					if ll[j] > 0:
						ans[i] = d[j]
						ll[j] -= 1
						break
		print('Yes')
		print(''.join(ans))
	else:
		print('No')


ts = int(input())
while ts > 0:
	ts -= 1
	n = int(input())
	(r, p, s) = map(int, input().split())
	s1 = input()
	s1 = s1.replace('S', 'r')
	s1 = s1.replace('R', 'p')
	s1 = s1.replace('P', 's')
	sl = []
	wn = n
	for c in s1:
		if c == 'r' and r > 0:
			r -= 1
		elif c == 'p' and p > 0:
			p -= 1
		elif c == 's' and s > 0:
			s -= 1
		else:
			wn -= 1
			c = 'a'
		sl.append(c)
	if wn * 2 < n:
		print('NO')
		continue
	print('YES')
	i = 0
	while i < n:
		if sl[i] == 'a':
			if s > 0:
				sl[i] = 's'
				s -= 1
			elif r > 0:
				sl[i] = 'r'
				r -= 1
			elif p > 0:
				sl[i] = 'p'
				p -= 1
		i += 1
	s2 = ''.join(sl)
	print(s2.upper())


def read():
	n = int(input())
	(r, p, s) = map(int, input().split())
	a = input()
	return (n, r, p, s, a)

def solve(n, r, p, s, a):
	b: list = [None] * n
	score = 0
	for i in range(n):
		if a[i] == 'R':
			if p > 0:
				b[i] = 'P'
				p -= 1
				score += 1
	for i in range(n):
		if a[i] == 'P':
			if s > 0:
				b[i] = 'S'
				s -= 1
				score += 1
	for i in range(n):
		if a[i] == 'S':
			if r > 0:
				b[i] = 'R'
				r -= 1
				score += 1
	if score < (n + 1) // 2:
		return None
	for i in range(n):
		if not b[i]:
			if r > 0:
				b[i] = 'R'
				r -= 1
			elif p > 0:
				b[i] = 'P'
				p -= 1
			else:
				b[i] = 'S'
				s -= 1
	return ''.join(b)
for t in range(int(input())):
	result = solve(*read())
	if result:
		print('YES')
		print(result)
	else:
		print('NO')


from math import ceil

def solve():
	nn = int(input())
	ss = 0
	(a, b, c) = map(int, input().split())
	hello = input()
	sss = ['-1'] * nn
	for i in range(0, nn):
		if hello[i] == 'R':
			if b > 0:
				sss[i] = 'P'
				ss += 1
				b -= 1
		elif hello[i] == 'P':
			if c > 0:
				sss[i] = 'S'
				ss += 1
				c -= 1
		elif hello[i] == 'S':
			if a > 0:
				sss[i] = 'R'
				ss += 1
				a -= 1
	for i in range(0, nn):
		if sss[i] == '-1':
			if a > 0:
				sss[i] = 'R'
				a -= 1
			elif b > 0:
				sss[i] = 'P'
				b -= 1
			elif c > 0:
				sss[i] = 'S'
				c -= 1
	if ss >= ceil(nn / 2):
		print('YES')
		print(''.join(sss))
	else:
		print('NO')
t = int(input())
for _ in range(0, t):
	solve()


import math
q = int(input())
for _ in range(q):
	n = int(input())
	(a, b, c) = map(int, input().split(' '))
	bob = input()
	alice = ['X'] * n
	cnt = 0
	for i in range(n):
		s = bob[i]
		if s == 'R' and b > 0:
			b = b - 1
			cnt = cnt + 1
			alice[i] = 'P'
		elif s == 'P' and c > 0:
			c = c - 1
			cnt = cnt + 1
			alice[i] = 'S'
		elif s == 'S' and a > 0:
			a = a - 1
			cnt = cnt + 1
			alice[i] = 'R'
	if (n + 1) // 2 <= cnt:
		win = ''
		for i in range(n):
			if alice[i] == 'X':
				if a > 0:
					a = a - 1
					win = win + 'R'
				elif b > 0:
					b = b - 1
					win = win + 'P'
				elif c > 0:
					c = c - 1
					win = win + 'S'
			else:
				win = win + alice[i]
		print('YES')
		print(win)
	else:
		print('NO')


tes = int(input())
for te in range(0, tes):
	n = int(input())
	(a, b, c) = input().split()
	a = int(a)
	b = int(b)
	c = int(c)
	st = input()
	countr = st.count('R')
	countp = st.count('P')
	counts = st.count('S')
	wins = min(countr, b) + min(countp, c) + min(counts, a)
	tem = 0
	la = 0
	lb = 0
	lc = 0
	if a > counts:
		la = a - counts
	if b > countr:
		lb = b - countr
	if c > countp:
		lc = c - countp
	if wins >= (n + 1) // 2:
		print('YES')
		arr = 'R' * la + 'P' * lb + 'S' * lc
		for i in range(0, len(st)):
			k = 0
			if st[i] == 'R':
				if b > 0:
					k = 1
					print('P', end='')
					b = b - 1
			if st[i] == 'P':
				if c > 0:
					k = 1
					print('S', end='')
					c = c - 1
			if st[i] == 'S':
				if a > 0:
					k = 1
					print('R', end='')
					a = a - 1
			if k == 0:
				print(arr[tem], end='')
				tem += 1
		print('')
	else:
		print('NO')


x = eval(input())
import math
for i in range(x):
	n = eval(input())
	y = input().split(' ')
	r = int(y[0])
	p = int(y[1])
	s = int(y[2])
	y = list(input())
	(R, P, S) = (0, 0, 0)
	a = 0
	for j in range(len(y)):
		if y[j] == 'R' and P < p:
			P += 1
			y[j] = 'P'
		elif y[j] == 'P' and S < s:
			S += 1
			y[j] = 'S'
		elif y[j] == 'S' and R < r:
			R += 1
			y[j] = 'R'
		else:
			y[j] = '0'
	if P + S + R >= math.ceil(n / 2):
		a = 1
	for k in range(len(y)):
		if y[k] == '0' and P < p:
			P += 1
			y[k] = 'P'
		elif y[k] == '0' and R < r:
			R += 1
			y[k] = 'R'
		elif y[k] == '0' and S < s:
			S += 1
			y[k] = 'S'
	if a == 1:
		print('YES')
		print(''.join(y))
	else:
		print('NO')


import bisect
import decimal
from decimal import Decimal
import os
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate
decimal.getcontext().prec = 46

def primeFactors(n):
	prime = set()
	while n % 2 == 0:
		prime.add(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			prime.add(i)
			n = n // i
	if n > 2:
		prime.add(n)
	return list(prime)

def getFactors(n):
	factors = []
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			if n // i == i:
				factors.append(i)
			else:
				factors.append(i)
				factors.append(n // i)
		i = i + 1
	return factors

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	num = []
	for p in range(2, n + 1):
		if prime[p]:
			num.append(p)
	return num

def lcm(a, b):
	return a * b // math.gcd(a, b)

def sort_dict(key_value):
	return sorted(key_value.items(), key=lambda kv: (kv[1], kv[0]))

def list_input():
	return list(map(int, input().split()))

def num_input():
	return map(int, input().split())

def string_list():
	return list(input())

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def binaryToDecimal(n):
	return int(n, 2)

def DFS(n, s, adj):
	visited = [False for i in range(n)]
	stack = []
	stack.append(s)
	while len(stack):
		s = stack[-1]
		stack.pop()
		if not visited[s]:
			visited[s] = True
		for node in adj[s]:
			if not visited[node]:
				stack.append(node)

def solve():
	n = int(input())
	(r, p, s) = num_input()
	move = list(input())
	ans = ''
	win = 0
	for i in range(n):
		if move[i] == 'R' and p > 0:
			win += 1
			p -= 1
			ans += 'P'
		elif move[i] == 'P' and s > 0:
			win += 1
			s -= 1
			ans += 'S'
		elif move[i] == 'S' and r > 0:
			win += 1
			r -= 1
			ans += 'R'
		else:
			ans += '_'
	if win >= math.ceil(n / 2):
		print('Yes')
		for i in ans:
			if i != '_':
				print(i, end='')
			elif r > 0:
				print('R', end='')
				r -= 1
			elif s > 0:
				print('S', end='')
				s -= 1
			else:
				print('P', end='')
				p -= 1
		print()
	else:
		print('No')
t = int(input())
for _ in range(t):
	solve()


switcher = {'R': 'S', 'S': 'P', 'P': 'R'}
st = 'RPS'
t = int(input())
while t > 0:
	t -= 1
	win = int(0)
	res = ['0'] * 100
	n = int(input())
	stra = [int()] * 3
	(stra[0], stra[1], stra[2]) = [int(x) for x in input().split()]
	bob = input()
	for i in range(0, 3):
		j = 0
		while stra[i] > 0 and j < len(bob):
			if switcher[st[i]] == bob[j]:
				stra[i] -= 1
				win += 1
				res[j] = st[i]
			j += 1
	if win >= n - win:
		print('YES')
		for i in range(0, 3):
			j = 0
			while stra[i] > 0 and j < len(bob):
				if res[j] == '0':
					res[j] = st[i]
					stra[i] -= 1
				j += 1
		final = ''
		for i in range(0, len(bob)):
			final += res[i]
		print(final)
	else:
		print('NO\n')


def solve():
	t = int(input())
	for i in range(0, t):
		n = int(input())
		(rock, paper, scissors) = map(int, input().split())
		s = input()
		w = 0
		r = []
		for x in s:
			if x == 'R':
				if paper > 0:
					w += 1
					paper -= 1
					r.append('P')
				else:
					r.append('0')
			elif x == 'P':
				if scissors > 0:
					w += 1
					scissors -= 1
					r.append('S')
				else:
					r.append('0')
			elif rock > 0:
				w += 1
				rock -= 1
				r.append('R')
			else:
				r.append('0')
		if rock > 0 or paper > 0 or scissors > 0:
			for i in range(0, len(r)):
				if r[i] == '0':
					if rock > 0:
						r[i] = 'R'
						rock -= 1
					elif paper > 0:
						r[i] = 'P'
						paper -= 1
					else:
						r[i] = 'S'
						scissors -= 1
		if w >= (n + 1) // 2:
			print('YES')
			print(''.join(r))
		else:
			print('NO')
solve()


for _ in range(int(input())):
	n = int(input())
	(r, p, s) = map(int, input().split())
	st = input()
	(R, P, S) = (0, 0, 0)
	for i in st:
		if i == 'R':
			R += 1
		elif i == 'P':
			P += 1
		else:
			S += 1
	wins = min(R, p) + min(P, s) + min(S, r)
	if 2 * wins >= n:
		print('yes')
		answers = [None] * n
		for i in range(n):
			if st[i] == 'R' and p > 0:
				p -= 1
				answers[i] = 'P'
			elif st[i] == 'P' and s > 0:
				s -= 1
				answers[i] = 'S'
			elif st[i] == 'S' and r > 0:
				r -= 1
				answers[i] = 'R'
		for i in range(n):
			if answers[i] == None:
				if r > 0:
					r -= 1
					answers[i] = 'R'
				elif s > 0:
					s -= 1
					answers[i] = 'S'
				else:
					answers[i] = 'P'
		for i in answers:
			print(i, end='')
		print('')
	else:
		print('no')


t = int(input())
for _ in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	rps_a = {'R': a, 'P': b, 'S': c}
	rps_b = {'R': 0, 'P': 0, 'S': 0}
	winner = {'R': 'P', 'P': 'S', 'S': 'R'}
	total = 0
	res = [''] * n
	for c in 'RPS':
		w = winner[c]
		for i in range(n):
			if s[i] == c and rps_a[w] > 0:
				rps_a[w] -= 1
				total += 1
				res[i] = w
	for i in range(n):
		if res[i] == '':
			for c in 'RPS':
				if rps_a[c] > 0:
					res[i] = c
					rps_a[c] -= 1
					break
	if total < n // 2 + n % 2:
		print('NO')
	else:
		print('YES')
		print(''.join(res))


from functools import reduce
import os
import sys
from collections import *
from math import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def arr():
	return [int(i) for i in input().split()]

def sarr():
	return [int(i) for i in input()]

def starr():
	return [str(x) for x in input().split()]

def inn():
	return int(input())

def svalue():
	return tuple(map(str, input().split()))

def parr():
	return [value() for i in range(n)]
mo = 1000000007
inf = 1e+18
div = 998244353
for _ in range(inn()):
	n = inn()
	(r, p, c) = value()
	s = input()
	cr = s.count('R')
	cp = s.count('P')
	cs = s.count('S')
	val = min(r, cs) + min(c, cp) + min(p, cr)
	if ceil(n / 2) > val:
		print('NO')
	else:
		print('YES')
		ans = ['-1'] * n
		for i in range(n):
			if s[i] == 'R':
				if p > 0:
					ans[i] = 'P'
					p -= 1
			elif s[i] == 'P':
				if c > 0:
					ans[i] = 'S'
					c -= 1
			elif r > 0:
				ans[i] = 'R'
				r -= 1
		for i in range(n):
			if ans[i] == '-1':
				if r > 0:
					ans[i] = 'R'
					r -= 1
				elif c > 0:
					ans[i] = 'S'
					c -= 1
				else:
					ans[i] = 'P'
					p -= 1
		print(*ans, sep='')


from sys import stdin
from collections import deque
from math import sqrt, floor, ceil, log, log2, log10, pi

def ii():
	return int(stdin.readline())

def fi():
	return float(stdin.readline())

def mi():
	return map(int, stdin.readline().split())

def fmi():
	return map(float, stdin.readline().split())

def li():
	return list(mi())

def si():
	return stdin.readline()
for _ in range(ii()):
	n = ii()
	x = [0] * n
	(r, p, s) = mi()
	a = si()
	w = 0
	for i in range(n):
		if a[i] == 'R' and p:
			p -= 1
			w += 1
			x[i] = 'P'
		elif a[i] == 'S' and r:
			r -= 1
			w += 1
			x[i] = 'R'
		elif a[i] == 'P' and s:
			s -= 1
			w += 1
			x[i] = 'S'
	if w >= (n + 1) // 2:
		print('YES')
		for i in range(n):
			if x[i] == 0:
				if p:
					x[i] = 'P'
					p -= 1
				elif r:
					x[i] = 'R'
					r -= 1
				else:
					x[i] = 'S'
					s -= 1
		print(*x, sep='')
	else:
		print('NO')


T = int(input())
for t in range(T):
	n = int(input())
	(r, p, s) = map(int, input().split())
	seq = input().strip()
	ans = ['' for i in seq]
	(x, y, z) = (0, 0, 0)
	for (i, k) in enumerate(seq):
		if k == 'S' and x < r:
			ans[i] = 'R'
			x += 1
		if k == 'R' and y < p:
			ans[i] = 'P'
			y += 1
		if k == 'P' and z < s:
			ans[i] = 'S'
			z += 1
	wins = x + y + z
	for (i, k) in enumerate(ans):
		if k:
			continue
		if x < r:
			ans[i] = 'R'
			x += 1
		elif y < p:
			ans[i] = 'P'
			y += 1
		elif z < s:
			ans[i] = 'S'
			z += 1
	from math import ceil
	if wins >= ceil(n / 2):
		print('YES')
		print(''.join(ans))
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	su = 0
	a2 = s.count('R')
	b2 = s.count('P')
	c2 = s.count('S')
	su = min(c2, a) + min(a2, b) + min(b2, c)
	ans = [None] * n
	if su * 2 < n:
		print('No')
	else:
		for i in range(n):
			if s[i] == 'R' and b > 0:
				ans[i] = 'P'
				b -= 1
			elif s[i] == 'P' and c > 0:
				ans[i] = 'S'
				c -= 1
			elif s[i] == 'S' and a > 0:
				a -= 1
				ans[i] = 'R'
			else:
				ans[i] = '_'
		for j in range(n):
			if ans[j] == '_' and a > 0:
				ans[j] = 'R'
				a -= 1
			elif ans[j] == '_' and b > 0:
				ans[j] = 'P'
				b -= 1
			elif ans[j] == '_' and c > 0:
				ans[j] = 'S'
				c -= 1
		print('Yes')
		print(''.join(ans))


def kkk(a, b, c, x, y, z):
	return min(x, b) + min(c, y) + min(a, z)

def ans(s, a, b, c):
	ss = list(s)
	answer = [''] * len(s)
	for i in range(len(s)):
		if ss[i] == 'R' and b > 0:
			answer[i] = 'P'
			b -= 1
		elif ss[i] == 'P' and c > 0:
			answer[i] = 'S'
			c -= 1
		elif ss[i] == 'S' and a > 0:
			answer[i] = 'R'
			a -= 1
	for i in range(len(s)):
		if answer[i] == '':
			if a > 0:
				answer[i] = 'R'
				a -= 1
			elif b > 0:
				answer[i] = 'P'
				b -= 1
			else:
				answer[i] = 'S'
	return ''.join(answer)
for i in range(int(input())):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	(x, y, z) = (s.count('R'), s.count('P'), s.count('S'))
	k = kkk(a, b, c, x, y, z)
	if 2 * k >= n:
		print('YES')
		print(ans(s, a, b, c))
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	res = [0 for _ in range(n)]
	a1 = b1 = c1 = 0
	use = []
	for i in range(n):
		if s[i] == 'P':
			if c > 0:
				c -= 1
				res[i] = 'S'
			else:
				use.append(i)
		elif s[i] == 'S':
			if a > 0:
				a -= 1
				res[i] = 'R'
			else:
				use.append(i)
		elif b > 0:
			b -= 1
			res[i] = 'P'
		else:
			use.append(i)
	if n - len(use) < (n + 1) // 2:
		print('NO')
	else:
		print('YES')
		for i in res:
			if i != 0:
				print(i, end='')
			elif c > 0:
				c -= 1
				print('S', end='')
			elif b > 0:
				b -= 1
				print('P', end='')
			elif a > 0:
				a -= 1
				print('R', end='')
		if n:
			print()


import math
t = int(input())
rules = {'S': 0, 'P': 2, 'R': 1}
for_answer = 'RPS'
for i in range(t):
	n = int(input())
	nums = [int(x) for x in input().split(' ')]
	bob = input()
	answer = []
	win = 'YES'
	count = 0
	for choise in bob:
		result = rules[choise]
		if nums[result] > 0:
			count += 1
			answer.append(for_answer[result])
		else:
			answer.append('$')
		nums[result] -= 1
	if count < math.ceil(n / 2):
		win = 'NO'
	else:
		for (j, a) in enumerate(answer):
			if a == '$':
				for i in range(3):
					if nums[i] > 0:
						nums[i] -= 1
						answer[j] = for_answer[i]
						break
				if answer[j] == '$':
					win = 'NO'
					break
	print(win)
	if win == 'YES':
		print(''.join(answer))


from collections import Counter, defaultdict, deque
from heapq import heapify, heappop, heappush
import sys, bisect, math, itertools, string, queue
sys.setrecursionlimit(10 ** 8)
mod = 10 ** 9 + 7

def inp():
	return int(sys.stdin.readline())

def inpl():
	return list(map(int, sys.stdin.readline().split()))

def inpl_str():
	return list(sys.stdin.readline().split())

def inpln(n):
	return list((int(sys.stdin.readline()) for i in range(n)))
t = inp()
nn = [0] * t
abc = [0] * t
ss = [0] * t
for i in range(t):
	nn[i] = inp()
	abc[i] = inpl()
	ss[i] = input()
for i in range(t):
	n = nn[i]
	(a, b, c) = (abc[i][0], abc[i][1], abc[i][2])
	s = ss[i]
	d = defaultdict(int)
	cnt = 0
	for i in s:
		d[i] += 1
	cnt += min(a, d['S'])
	cnt += min(b, d['R'])
	cnt += min(c, d['P'])
	if cnt >= -(-n // 2):
		print('YES')
		res = ''
		rem = [0, 0, 0]
		rem[0] = a - d['S'] if a > d['S'] else 0
		rem[1] = b - d['R'] if b > d['R'] else 0
		rem[2] = c - d['P'] if c > d['P'] else 0
		for (i, t) in enumerate(s):
			if t == 'R':
				if b > 0:
					res += 'P'
					b -= 1
					continue
				if rem[0] > 0:
					res += 'R'
					rem[0] -= 1
				else:
					res += 'S'
					rem[2] -= 1
			elif t == 'P':
				if c > 0:
					c -= 1
					res += 'S'
					continue
				if rem[0] > 0:
					res += 'R'
					rem[0] -= 1
				else:
					res += 'P'
					rem[1] -= 1
			else:
				if a > 0:
					a -= 1
					res += 'R'
					continue
				if rem[1] > 0:
					res += 'P'
					rem[1] -= 1
				else:
					res += 'S'
					rem[2] -= 1
		print(''.join(res))
	else:
		print('NO')


def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)
x = int(input())
for _ in range(x):
	input()
	(ra, pa, sa) = map(int, input().split())
	bob = input()
	(rb, pb, sb) = (bob.count('R'), bob.count('P'), bob.count('S'))
	(pw, sw, rw) = (min(rb, pa), min(pb, sa), min(sb, ra))
	(rl, pl, sl) = (ra - rw, pa - pw, sa - sw)
	a = []
	if 2 * (rw + pw + sw) >= len(bob):
		for m in bob:
			if m == 'R' and pw:
				a.append('P')
				pw -= 1
			elif m == 'P' and sw:
				a.append('S')
				sw -= 1
			elif m == 'S' and rw:
				a.append('R')
				rw -= 1
			elif rl:
				a.append('R')
				rl -= 1
			elif pl:
				a.append('P')
				pl -= 1
			elif sl:
				a.append('S')
				sl -= 1
		print('YES')
		print(''.join(a))
	else:
		print('NO')


import math
t = int(input())
for j in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	a1 = 0
	b1 = 0
	c1 = 0
	m = list(input())
	for i in m:
		if i == 'R':
			b1 += 1
		elif i == 'P':
			c1 += 1
		elif i == 'S':
			a1 += 1
	w = math.ceil(n / 2)
	a2 = min(a, a1)
	b2 = min(b, b1)
	c2 = min(c, c1)
	if a2 + b2 + c2 < w:
		print('NO')
	else:
		print('YES')
		for i in range(n):
			if m[i] == 'R' and b2 > 0:
				m[i] = 'P'
				b2 -= 1
				b -= 1
			elif m[i] == 'P' and c2 > 0:
				m[i] = 'S'
				c2 -= 1
				c -= 1
			elif m[i] == 'S' and a2 > 0:
				m[i] = 'R'
				a2 -= 1
				a -= 1
			else:
				m[i] = '_'
		for i in range(n):
			if m[i] == '_':
				if a > 0:
					m[i] = 'R'
					a -= 1
				elif b > 0:
					m[i] = 'P'
					b -= 1
				elif c > 0:
					m[i] = 'S'
					c -= 1
		m1 = ''.join(m)
		print(m1)


mod = 10 ** 9 + 7
import sys
sys.setrecursionlimit(10 ** 6)
from sys import stdin, stdout
import bisect
from bisect import bisect_left as bl
from bisect import bisect_right as br
import itertools
import collections
import math
import heapq
import random

def modinv(n, p):
	return pow(n, p - 2, p)

def ncr(n, r, p):
	t = fact[n] * (ifact[r] * ifact[n - r] % p) % p
	return t

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())

def GCD(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def main():
	t = inin()
	for _ in range(t):
		n = inin()
		(j, k, l) = cin()
		u = j
		v = k
		w = l
		s = sin()
		jj = kk = ll = 0
		for i in s:
			if i == 'S':
				jj += 1
			elif i == 'P':
				ll += 1
			else:
				kk += 1
		j = min(jj, j)
		k = min(kk, k)
		l = min(ll, l)
		x = j + k + l
		if x >= math.ceil(n / 2):
			print('YES')
			d = ''
			for i in s:
				if i == 'S' and j > 0:
					u -= 1
					j -= 1
					d += 'R'
				elif i == 'P' and l > 0:
					w -= 1
					l -= 1
					d += 'S'
				elif i == 'R' and k > 0:
					v -= 1
					k -= 1
					d += 'P'
				else:
					d += '-'
			for i in d:
				if i != '-':
					print(i, end='')
				elif u > 0:
					print('R', end='')
					u -= 1
				elif v > 0:
					print('P', end='')
					v -= 1
				else:
					print('S', end='')
					w -= 1
			print()
		else:
			print('NO')
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def readnumbers(zero=0):
	conv = ord if py2 else lambda x: x
	A = []
	numb = zero
	sign = 1
	i = 0
	s = sys.stdin.buffer.read()
	try:
		while True:
			if s[i] >= b'0'[0]:
				numb = 10 * numb + conv(s[i]) - 48
			elif s[i] == b'-'[0]:
				sign = -1
			elif s[i] != b'\r'[0]:
				A.append(sign * numb)
				numb = zero
				sign = 1
			i += 1
	except:
		pass
	if s and s[-1] >= b'0'[0]:
		A.append(sign * numb)
	return A
main()


import sys
input = sys.stdin.readline
import collections

def main():
	t = int(input())
	for _ in range(t):
		N = int(input())
		(A, B, C) = [int(x) for x in input().split()]
		S = input().strip()
		c = collections.Counter(S)
		x = 0
		x += min(c['S'], A)
		x += min(c['R'], B)
		x += min(c['P'], C)
		A_amari = 0
		B_amari = 0
		C_amari = 0
		if c['S'] < A:
			A_amari = A - c['S']
		if c['R'] < B:
			B_amari = B - c['R']
		if c['P'] < C:
			C_amari = C - c['P']
		if x >= -(-N // 2):
			print('YES')
			for s in S:
				if s == 'S':
					if A > 0:
						print('R', end='')
						A -= 1
					elif B_amari > 0:
						print('P', end='')
						B_amari -= 1
					elif C_amari > 0:
						print('S', end='')
						C_amari -= 1
				elif s == 'R':
					if B > 0:
						print('P', end='')
						B -= 1
					elif A_amari > 0:
						print('R', end='')
						A_amari -= 1
					elif C_amari > 0:
						print('S', end='')
						C_amari -= 1
				elif s == 'P':
					if C > 0:
						print('S', end='')
						C -= 1
					elif B_amari > 0:
						print('P', end='')
						B_amari -= 1
					elif A_amari > 0:
						print('R', end='')
						A_amari -= 1
			print('')
		else:
			print('NO')
main()


from collections import defaultdict, deque
from itertools import permutations
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
from copy import deepcopy
import math
int_input = lambda : int(stdin.readline())
string_input = lambda : stdin.readline()
multi_int_input = lambda : map(int, stdin.readline().split())
multi_input = lambda : stdin.readline().split()
list_input = lambda : list(map(int, stdin.readline().split()))
string_list_input = lambda : list(string_input())
MOD = pow(10, 9) + 7
test = int_input()
for _ in range(test):
	n = int_input()
	RPS = list_input()
	RPS_COPY = RPS
	sequence = string_input()
	win = 0
	winseq = ''
	for char in sequence:
		if char == 'R':
			if RPS[1] > 0:
				RPS[1] -= 1
				winseq += 'P'
				win += 1
			else:
				winseq += '*'
		elif char == 'P':
			if RPS[2] > 0:
				RPS[2] -= 1
				winseq += 'S'
				win += 1
			else:
				winseq += '*'
		elif char == 'S':
			if RPS[0] > 0:
				RPS[0] -= 1
				winseq += 'R'
				win += 1
			else:
				winseq += '*'
	finalWINSeq = ''
	if win >= math.ceil(n / 2):
		print('YES')
		for i in winseq:
			if i is not '*':
				finalWINSeq += i
			elif RPS[0] > 0:
				finalWINSeq += 'R'
				RPS[0] -= 1
			elif RPS[1] > 0:
				finalWINSeq += 'P'
				RPS[1] -= 1
			elif RPS[2] > 0:
				finalWINSeq += 'S'
				RPS[2] -= 1
		print(finalWINSeq)
	else:
		print('NO')


t = input()
t = int(t)
for i in range(t):
	n = input()
	n = int(n)
	(a, b, c) = input().split()
	a = int(a)
	b = int(b)
	c = int(c)
	s = input()
	lose = 0
	way = []
	for ch in s:
		if ch == 'R' and b > 0:
			b -= 1
			way.append('P')
		elif ch == 'P' and c > 0:
			c -= 1
			way.append('S')
		elif ch == 'S' and a > 0:
			a -= 1
			way.append('R')
		else:
			lose += 1
			way.append('T')
	if lose > n // 2:
		print('NO')
		continue
	print('YES')
	for ch in way:
		if ch == 'T':
			if a > 0:
				a -= 1
				print('R', end='')
			elif b > 0:
				b -= 1
				print('P', end='')
			else:
				c -= 1
				print('S', end='')
		else:
			print(ch, end='')
	print()


t = int(input())
for i in range(t):
	n = int(input())
	(a, b, c) = [int(i) for i in input().split()]
	s = input()
	R = P = S = 0
	seq = [''] * n
	(na, nb, nc) = (a, b, c)
	for i in range(len(s)):
		if s[i] == 'R':
			R += 1
			if nb:
				seq[i] = 'P'
				nb -= 1
		elif s[i] == 'P':
			P += 1
			if nc:
				seq[i] = 'S'
				nc -= 1
		else:
			S += 1
			if na:
				seq[i] = 'R'
				na -= 1
	amount = min(R, b) + min(P, c) + min(S, a)
	if amount < int(n / 2 + 0.5):
		print('NO')
		continue
	print('YES')
	for i in range(n):
		if seq[i] == '' and na > 0:
			seq[i] = 'R'
			na -= 1
		elif seq[i] == '' and nb > 0:
			seq[i] = 'P'
			nb -= 1
		elif seq[i] == '' and nc > 0:
			seq[i] = 'S'
			nc -= 1
	print(''.join(seq))


from math import gcd
t = int(input())
for q in range(t):
	nn = int(input())
	(k, b, n) = map(int, input().split())
	s = input()
	w = 0
	aaa = [0] * nn
	for i in range(nn):
		if s[i] == 'R' and b:
			w += 1
			b -= 1
			aaa[i] = 'P'
		elif s[i] == 'P' and n:
			w += 1
			n -= 1
			aaa[i] = 'S'
		elif s[i] == 'S' and k:
			w += 1
			k -= 1
			aaa[i] = 'R'
	for i in range(nn):
		if type(aaa[i]) == int:
			if k:
				k -= 1
				aaa[i] = 'R'
			elif b:
				b -= 1
				aaa[i] = 'P'
			else:
				n -= 1
				aaa[i] = 'S'
	if nn // 2 + nn % 2 <= w:
		print('YES')
		print(''.join(aaa))
	else:
		print('NO')


import math
for t in range(int(input())):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	x = s.count('R')
	y = s.count('P')
	z = s.count('S')
	c1 = min(b, x)
	c2 = min(c, y)
	c3 = min(z, a)
	e1 = a - z
	e2 = b - x
	e3 = c - y
	cnt = c1 + c2 + c3
	if cnt >= math.ceil(n / 2):
		print('YES')
		for k in range(n):
			if s[k] == 'R':
				if c1 > 0:
					print('P', end='')
					c1 -= 1
				elif e1 > 0:
					print('R', end='')
					e1 -= 1
				else:
					print('S', end='')
					e3 -= 1
			if s[k] == 'P':
				if c2 > 0:
					print('S', end='')
					c2 -= 1
				elif e2 > 0:
					print('P', end='')
					e2 -= 1
				else:
					print('R', end='')
					e1 -= 1
			if s[k] == 'S':
				if c3 > 0:
					print('R', end='')
					c3 -= 1
				elif e2 > 0:
					print('P', end='')
					e2 -= 1
				else:
					print('S', end='')
					e3 -= 1
		print()
	else:
		print('NO')


import math
t = int(input())
while t:
	n = int(input())
	(ro, pa, si) = map(int, input().split())
	s = input()
	s1 = ''
	c = 0
	for i in range(n):
		if s[i] == 'R':
			if pa > 0:
				s1 += 'P'
				pa -= 1
				c += 1
			else:
				s1 += '0'
		elif s[i] == 'P':
			if si > 0:
				s1 += 'S'
				si -= 1
				c += 1
			else:
				s1 += '0'
		elif ro > 0:
			s1 += 'R'
			ro -= 1
			c += 1
		else:
			s1 += '0'
	if c >= math.ceil(n / 2):
		print('YES')
		s2 = ''
		for i in s1:
			if i != '0':
				s2 += i
			elif ro > 0:
				s2 += 'R'
				ro -= 1
			elif pa > 0:
				s2 += 'P'
				pa -= 1
			else:
				s2 += 'S'
				si -= 1
		print(s2)
	else:
		print('NO')
	t -= 1


import math
from collections import Counter

def li():
	return [int(i) for i in input().split(' ')]

def val():
	return int(input())

def st():
	return input()
for _ in range(val()):
	n = val()
	l = li()
	s = st()
	temp = s
	s = Counter(s)
	tot = 0
	tot += min(l[0], s['S'])
	tot += min(l[1], s['R'])
	tot += min(l[2], s['P'])
	s = temp
	if tot >= math.ceil(n / 2):
		print('YES')
		ans = ''
		i = tot = 0
		cal = math.ceil(n / 2)
		while cal > tot and i < len(s):
			if temp[i] == 'S':
				if l[0]:
					tot += 1
					ans += 'R'
					l[0] -= 1
				else:
					ans += ' '
			elif temp[i] == 'R':
				if l[1]:
					ans += 'P'
					l[1] -= 1
					tot += 1
				else:
					ans += ' '
			elif temp[i] == 'P':
				if l[2]:
					tot += 1
					ans += 'S'
					l[2] -= 1
				else:
					ans += ' '
			i += 1
		ans = list(ans)
		for i in range(0, len(ans)):
			if ans[i] == ' ':
				if l[0]:
					ans[i] = 'R'
					l[0] -= 1
				elif l[1]:
					ans[i] = 'P'
					l[1] -= 1
				else:
					l[2] -= 1
					ans[i] = 'S'
		ans += 'R' * l[0]
		ans += 'S' * l[2]
		ans += 'P' * l[1]
		print(*ans, sep='')
	else:
		print('NO')


from math import ceil
for i in range(int(input())):
	n = int(input())
	(a, b, c) = [int(x) for x in input().split()]
	s = input()
	bb = min(s.count('R'), b)
	cc = min(s.count('P'), c)
	aa = min(s.count('S'), a)
	if int(ceil(n / 2)) <= aa + bb + cc:
		print('YES')
		for k in s:
			if k == 'R':
				if bb > 0:
					print('P', end='')
					bb -= 1
					b -= 1
				elif a - aa > c - cc:
					print('R', end='')
					if a == aa:
						a -= 1
						aa -= 1
					else:
						a -= 1
				else:
					print('S', end='')
					if c == cc:
						c -= 1
						cc -= 1
					else:
						c -= 1
			elif k == 'P':
				if cc > 0:
					print('S', end='')
					cc -= 1
					c -= 1
				elif a - aa > b - bb:
					print('R', end='')
					if a == aa:
						a -= 1
						aa -= 1
					else:
						a -= 1
				else:
					print('P', end='')
					if b == bb:
						b -= 1
						bb -= 1
					else:
						b -= 1
			elif aa > 0:
				print('R', end='')
				aa -= 1
				a -= 1
			elif c - cc > b - bb:
				print('S', end='')
				if c == cc:
					c -= 1
					cc -= 1
				else:
					c -= 1
			else:
				print('P', end='')
				if b == bb:
					b -= 1
					bb -= 1
				else:
					b -= 1
	else:
		print('NO', end='')
	print('')


import math, string, itertools, fractions, heapq, collections, re, array, bisect
YES = 'YES'
NO = 'NO'
t = int(input())
for i in range(t):
	n = int(input())
	(r, p, s) = map(int, input().split())
	bob = input()
	R = bob.count('R')
	S = bob.count('S')
	P = bob.count('P')
	winScore = int(math.ceil(n / 2))
	score = 0
	inHand = []
	if r > 0:
		if r >= S:
			score += S
			inHand += ['R'] * S
		if r < S:
			score += r
			inHand += ['R'] * r
	if p > 0:
		if p >= R:
			score += R
			inHand += ['P'] * R
		if p < R:
			score += p
			inHand += ['P'] * p
	if s > 0:
		if s >= P:
			score += P
			inHand += ['S'] * P
		if s < P:
			score += s
			inHand += ['S'] * s
	r -= inHand.count('R')
	p -= inHand.count('P')
	s -= inHand.count('S')
	if score >= winScore:
		print(YES)
		play = ''
		for bobPlayed in bob:
			if bobPlayed == 'R':
				if 'P' in inHand:
					play += 'P'
					inHand.remove('P')
				else:
					if r > 0:
						play += 'R'
						r -= 1
						continue
					if s > 0:
						play += 'S'
						s -= 1
						continue
			if bobPlayed == 'P':
				if 'S' in inHand:
					play += 'S'
					inHand.remove('S')
				else:
					if p > 0:
						play += 'P'
						p -= 1
						continue
					if r > 0:
						play += 'R'
						r -= 1
						continue
			if bobPlayed == 'S':
				if 'R' in inHand:
					play += 'R'
					inHand.remove('R')
				else:
					if p > 0:
						play += 'P'
						p -= 1
						continue
					if s > 0:
						play += 'S'
						s -= 1
						continue
		print(play)
	else:
		print(NO)


from collections import Counter
from math import ceil
for _ in range(int(input())):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	cnt = Counter(s)
	ans = [-1] * n
	ra = min(cnt['R'], b)
	rb = min(cnt['P'], c)
	rc = min(cnt['S'], a)
	if ra + rb + rc >= ceil(n / 2):
		print('YES')
		b -= ra
		c -= rb
		a -= rc
		for i in range(n):
			if s[i] == 'R':
				if ra:
					ra -= 1
					ans[i] = 'P'
			if s[i] == 'P':
				if rb:
					rb -= 1
					ans[i] = 'S'
			if s[i] == 'S':
				if rc:
					rc -= 1
					ans[i] = 'R'
		for i in range(n):
			if ans[i] == -1:
				if b:
					b -= 1
					ans[i] = 'P'
				elif c:
					c -= 1
					ans[i] = 'S'
				elif a:
					a -= 1
					ans[i] = 'R'
		print(''.join(ans))
	else:
		print('NO')


import math
t = int(input())
for q in range(t):
	n = int(input())
	(r, p, st) = map(int, input().split())
	s = list(input())
	count = 0
	for i in range(len(s)):
		if s[i] == 'R':
			if p > 0:
				s[i] = 'P'
				p -= 1
				count += 1
			else:
				s[i] = 0
		elif s[i] == 'P':
			if st > 0:
				s[i] = 'S'
				st -= 1
				count += 1
			else:
				s[i] = 0
		elif s[i] == 'S':
			if r > 0:
				s[i] = 'R'
				r -= 1
				count += 1
			else:
				s[i] = 0
	for i in range(len(s)):
		if s[i] == 0:
			if st > 0:
				s[i] = 'S'
				st -= 1
			elif r > 0:
				s[i] = 'R'
				r -= 1
			elif p > 0:
				s[i] = 'P'
				p -= 1
	if count < math.ceil(n / 2):
		print('NO')
	else:
		print('YES')
		ans = ''
		for i in range(len(s)):
			ans += s[i]
		print(ans)


from sys import *
from math import *
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	(a, b, c) = map(int, stdin.readline().split())
	s1 = input()
	r = p = s = 0
	for i in range(n):
		if s1[i] == 'R':
			r += 1
		elif s1[i] == 'P':
			p += 1
		else:
			s += 1
	a1 = min(a, s)
	a2 = min(b, r)
	a3 = min(c, p)
	x = a1 + a2 + a3
	if float(x) >= n / 2:
		print('YES')
		ans = [0] * n
		f = [0] * n
		for i in range(n):
			if s1[i] == 'S' and a > 0:
				a -= 1
				ans[i] = 'R'
				f[i] = 1
			if s1[i] == 'R' and b > 0:
				b -= 1
				ans[i] = 'P'
				f[i] = 1
			if s1[i] == 'P' and c > 0:
				c -= 1
				ans[i] = 'S'
				f[i] = 1
		for i in range(n):
			m = max(a, b, c)
			if f[i] == 0:
				if m == a:
					ans[i] = 'R'
					a -= 1
				elif m == b:
					ans[i] = 'P'
					b -= 1
				else:
					ans[i] = 'S'
					c -= 1
		print(*ans, sep='')
	else:
		print('NO')


import math
t = int(input())
for i in range(t):
	n = int(input())
	[R, P, S] = [int(x) for x in input().split()]
	hody = list(input())
	r = 0
	p = 0
	s = 0
	out = ''
	for hod in hody:
		if hod == 'R':
			r += 1
		if hod == 'P':
			p += 1
		if hod == 'S':
			s += 1
	r_used = 0
	p_used = 0
	s_used = 0
	papierov = min(P, r)
	noznic = min(S, p)
	rockov = min(R, s)
	for hod in hody:
		if hod == 'R':
			if p_used < P:
				out += 'P'
				p_used += 1
			else:
				out += '?'
		if hod == 'P':
			if s_used < S:
				out += 'S'
				s_used += 1
			else:
				out += '?'
		if hod == 'S':
			if r_used < R:
				out += 'R'
				r_used += 1
			else:
				out += '?'
	out2 = ''
	for j in range(n):
		if out[j] == '?':
			if r_used < R:
				out2 += 'R'
				r_used += 1
			elif p_used < P:
				out2 += 'P'
				p_used += 1
			else:
				out2 += 'S'
		else:
			out2 += out[j]
	bodov = papierov + noznic + rockov
	if bodov < math.ceil(n / 2):
		print('NO')
	else:
		print('YES')
		print(out2)


import math
t = int(input())
while t > 0:
	n = int(input())
	(r, p, s) = map(int, input().split())
	seq = input()
	m = {'R': 0, 'P': 0, 'S': 0}
	for i in seq:
		m[i] += 1
	res = 0
	res += min(r, m['S'])
	res += min(p, m['R'])
	res += min(s, m['P'])
	if res >= math.ceil(n / 2):
		print('YES')
		ans = [0] * len(seq)
		for i in range(len(seq)):
			if seq[i] == 'R' and p > 0:
				ans[i] = 'P'
				p -= 1
			elif seq[i] == 'P' and s > 0:
				ans[i] = 'S'
				s -= 1
			elif seq[i] == 'S' and r > 0:
				ans[i] = 'R'
				r -= 1
		for i in range(len(ans)):
			if ans[i] == 0:
				if p > 0:
					ans[i] = 'P'
					p -= 1
				elif r > 0:
					ans[i] = 'R'
					r -= 1
				elif s > 0:
					ans[i] = 'S'
					s -= 1
		print(''.join(ans))
	else:
		print('NO')
	t -= 1


import io, sys, atexit, os
import math as ma
from sys import exit
from decimal import Decimal as dec
from itertools import permutations
from itertools import combinations

def li():
	return list(map(int, sys.stdin.readline().split()))

def num():
	return map(int, sys.stdin.readline().split())

def nu():
	return int(input())

def find_gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def lcm(x, y):
	gg = find_gcd(x, y)
	return x * y // gg
mm = 1000000007

def solve():
	t = nu()
	for tt in range(t):
		n = nu()
		(a, b, c) = num()
		ss = input()
		r = 0
		p = 0
		s = 0
		for i in range(n):
			if ss[i] == 'R':
				r += 1
			if ss[i] == 'P':
				p += 1
			if ss[i] == 'S':
				s += 1
		win = 0
		(one, two, three) = (0, 0, 0)
		win += min(a, s)
		win += min(b, r)
		win += min(c, p)
		if win >= int(ma.ceil(n / 2)):
			print('YES')
			x = min(a, s)
			y = min(b, r)
			z = min(c, p)
			ol = [0] * n
			for i in range(n):
				if ss[i] == 'S':
					if x != 0:
						ol[i] = 'R'
						x -= 1
				if ss[i] == 'R':
					if y != 0:
						ol[i] = 'P'
						y -= 1
				if ss[i] == 'P':
					if z != 0:
						ol[i] = 'S'
						z -= 1
			a -= min(a, s)
			b -= min(b, r)
			c -= min(c, p)
			while a != 0:
				for i in range(n):
					if ol[i] == 0:
						ol[i] = 'R'
						a -= 1
					if a == 0:
						break
			while b != 0:
				for i in range(n):
					if ol[i] == 0:
						ol[i] = 'P'
						b -= 1
					if b == 0:
						break
			while c != 0:
				for i in range(n):
					if ol[i] == 0:
						ol[i] = 'S'
						c -= 1
					if c == 0:
						break
			print(*ol, sep='')
		else:
			print('NO')
solve()


for _ in range(int(input())):
	n = int(input())
	(ro, pa, sc) = map(int, input().split())
	s = input()
	rock = s.count('R')
	paper = s.count('P')
	scissors = s.count('S')
	w = min(ro, scissors) + min(pa, rock) + min(sc, paper)
	if 2 * w < n:
		print('NO')
	else:
		print('YES')
		s1 = []
		for i in range(n):
			if s[i] == 'R' and pa:
				s1.append('P')
				pa = pa - 1
			elif s[i] == 'P' and sc:
				s1.append('S')
				sc = sc - 1
			elif s[i] == 'S' and ro:
				s1.append('R')
				ro = ro - 1
			else:
				s1.append('@')
		for i in range(n):
			if s1[i] == '@':
				if ro:
					s1[i] = 'R'
					ro = ro - 1
				elif pa:
					s1[i] = 'P'
					pa = pa - 1
				else:
					s1[i] = 'S'
					sc = sc - 1
		for i in range(n):
			print(s1[i], end='')
		print()


t = int(input())
for i in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = list(input())
	used = [0] * n
	for i in range(n):
		if s[i] == 'R' and b > 0:
			s[i] = 'P'
			b -= 1
			used[i] = 1
		elif s[i] == 'P' and c > 0:
			s[i] = 'S'
			c -= 1
			used[i] = 1
		elif s[i] == 'S' and a > 0:
			s[i] = 'R'
			a -= 1
			used[i] = 1
	if used.count(1) >= (n + 1) // 2:
		print('YES')
		for i in range(n):
			if used[i] == 0:
				if a > 0:
					s[i] = 'R'
					a -= 1
				elif b > 0:
					s[i] = 'P'
					b -= 1
				elif c > 0:
					s[i] = 'S'
					c -= 1
		print(''.join(s))
	else:
		print('NO')


def solve(n, r, p, s, bob):
	q = [''] * n
	count = 0
	for (i, ch) in enumerate(bob):
		if ch == 'R' and p > 0:
			p -= 1
			q[i] = 'P'
			count += 1
		elif ch == 'P' and s > 0:
			s -= 1
			q[i] = 'S'
			count += 1
		elif ch == 'S' and r > 0:
			r -= 1
			q[i] = 'R'
			count += 1
	if count < n // 2 + n % 2:
		return (False, '')
	for i in range(len(q)):
		if q[i] == '':
			if r > 0:
				q[i] = 'R'
				r -= 1
			elif p > 0:
				q[i] = 'P'
				p -= 1
			else:
				q[i] = 'S'
				s -= 1
	return (True, ''.join(q))

def win(b):
	if b == 'R':
		return 'P'
	if b == 'P':
		return 'S'
	if b == 'S':
		return 'R'
tests = int(input())
for i in range(tests):
	parts = int(input())
	line = input()
	r = int(line.split()[0])
	p = int(line.split()[1])
	s = int(line.split()[2])
	bob = input()
	(q, res) = solve(parts, r, p, s, bob)
	if q:
		print('YES')
		print(res)
	else:
		print('NO')


import sys
from collections import Counter
from math import ceil

def possible_wins(a, b, c, seq):
	co = Counter(seq)
	wins = 0
	wins += min(co['R'], b)
	wins += min(co['P'], c)
	wins += min(co['S'], a)
	return wins

def winning_seq(a, b, c, seq):
	winning_seq = [None] * (a + b + c)
	for (i, move) in enumerate(seq):
		if move == 'R' and b > 0:
			b -= 1
			winning_seq[i] = 'P'
		elif move == 'P' and c > 0:
			c -= 1
			winning_seq[i] = 'S'
		elif move == 'S' and a > 0:
			a -= 1
			winning_seq[i] = 'R'
	for (i, e) in enumerate(winning_seq):
		if e is None:
			if a > 0:
				a -= 1
				winning_seq[i] = 'R'
			elif b > 0:
				b -= 1
				winning_seq[i] = 'P'
			elif c > 0:
				c -= 1
				winning_seq[i] = 'S'
	return ''.join(winning_seq)

def main():
	t = int(sys.stdin.readline())
	(n, a, b, c, seq) = ([None] * t, [None] * t, [None] * t, [None] * t, [None] * t)
	for i in range(t):
		n[i] = int(sys.stdin.readline())
		(a[i], b[i], c[i]) = map(int, sys.stdin.readline().split())
		seq[i] = sys.stdin.readline().strip()
	for i in range(t):
		if possible_wins(a[i], b[i], c[i], seq[i]) >= ceil(n[i] / 2):
			print('YES')
			print(winning_seq(a[i], b[i], c[i], seq[i]))
		else:
			print('NO')
main()


from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
mod = 10 ** 9 + 7
import sys
sys.setrecursionlimit(10 ** 9)
t = int(input())
for _ in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	(a1, a2, a3) = (a, b, c)
	s = input()
	st1 = [''] * n
	count = 0
	for (j, i) in enumerate(s):
		if i == 'R' and b > 0:
			st1[j] = 'P'
			b -= 1
			count += 1
		elif i == 'P' and c > 0:
			st1[j] = 'S'
			c -= 1
			count += 1
		elif i == 'S' and a > 0:
			st1[j] = 'R'
			a -= 1
			count += 1
	i = 0
	while a > 0 and i < n:
		if st1[i] == '':
			st1[i] = 'R'
			a -= 1
		i += 1
	i = 0
	while b > 0 and i < n:
		if st1[i] == '':
			st1[i] = 'P'
			b -= 1
		i += 1
	i = 0
	while c > 0 and i < n:
		if st1[i] == '':
			st1[i] = 'S'
			c -= 1
		i += 1
	if count >= ceil(n / 2):
		print('YES')
		print(''.join(st1))
	else:
		print('NO')


test = int(input())
for num in range(test):
	n = int(input())
	temp = ''
	hudai = ''
	(a, b, c) = map(int, input().split())
	senten = input()
	l = len(senten)
	for i in range(l):
		if senten[i] == 'R':
			if b > 0:
				temp += 'P'
				b -= 1
			else:
				temp += '!'
		elif senten[i] == 'P':
			if c > 0:
				temp += 'S'
				c -= 1
			else:
				temp += '!'
		elif senten[i] == 'S':
			if a > 0:
				temp += 'R'
				a -= 1
			else:
				temp += '!'
	wait_bro = (n + 1) // 2
	if n - a - b - c < wait_bro:
		print('NO')
	else:
		print('YES')
		for laga in range(l):
			if temp[laga] != '!':
				hudai += temp[laga]
			elif a > 0:
				hudai += 'R'
				a -= 1
			elif b > 0:
				hudai += 'P'
				b -= 1
			else:
				hudai += 'S'
		print(hudai)


from math import *
q = int(input())
for t in range(q):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	ans = ['0'] * n
	an = 0
	for i in range(len(s)):
		if s[i] == 'R' and b > 0:
			ans[i] = 'P'
			b -= 1
			an += 1
		if s[i] == 'P' and c > 0:
			ans[i] = 'S'
			c -= 1
			an += 1
		if s[i] == 'S' and a > 0:
			ans[i] = 'R'
			a -= 1
			an += 1
	if an >= (n + 1) // 2:
		print('YES')
		for i in range(len(ans)):
			if ans[i] == '0':
				if a > 0:
					ans[i] = 'R'
					a -= 1
				elif b > 0:
					ans[i] = 'P'
					b -= 1
				else:
					ans[i] = 'S'
					c -= 1
		for i in range(len(ans)):
			print(ans[i], end='')
		print()
	else:
		print('NO')


import math
T = int(input())
while T:
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	t = ['X' for i in range(n)]
	count = 0
	for i in range(n):
		if s[i] == 'S' and a:
			t[i] = 'R'
			a -= 1
			count += 1
		if s[i] == 'R' and b:
			t[i] = 'P'
			b -= 1
			count += 1
		if s[i] == 'P' and c:
			t[i] = 'S'
			c -= 1
			count += 1
	if count < math.ceil(n / 2):
		print('NO')
	else:
		print('YES')
		for i in range(n):
			if t[i] == 'X':
				if a:
					t[i] = 'R'
					a -= 1
				elif b:
					t[i] = 'P'
					b -= 1
				else:
					t[i] = 'S'
					c -= 1
		print(''.join((str(x) for x in t)))
	T -= 1


t = int(input())
for i in range(t):
	n = int(input())
	(a, b, c) = [int(i) for i in input().split()]
	ch = input()
	L = ['R'] * a + ['P'] * b + ['S'] * c
	s = ['o'] * len(ch)
	nb = 0
	for i in range(len(ch)):
		if ch[i] == 'R':
			if L.count('P') > 0:
				L.remove('P')
				s[i] = 'P'
				nb += 1
		elif ch[i] == 'P':
			if L.count('S') > 0:
				L.remove('S')
				s[i] = 'S'
				nb += 1
		elif L.count('R') > 0:
			L.remove('R')
			s[i] = 'R'
			nb += 1
	for i in range(len(s)):
		if s[i] == 'o':
			s[i] = L[0]
			L.pop(0)
	s2 = ''
	for i in s:
		s2 += i
	if nb >= (n + 1) // 2:
		print('YES')
		print(s2)
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	k = 0
	p = [0] * n
	for i in range(n):
		if s[i] == 'R':
			if b > 0:
				b -= 1
				k += 1
				p[i] = 'P'
		if s[i] == 'P':
			if c > 0:
				c -= 1
				k += 1
				p[i] = 'S'
		if s[i] == 'S':
			if a > 0:
				a -= 1
				k += 1
				p[i] = 'R'
	if k >= (n + 1) // 2:
		print('YES')
		for i in range(n):
			if p[i] == 0:
				if a > 0:
					a -= 1
					p[i] = 'R'
				elif b > 0:
					b -= 1
					p[i] = 'P'
				elif c > 0:
					c -= 1
					p[i] = 'S'
		print(''.join(p))
	else:
		print('NO')


def main():
	import sys
	t = int(input())
	for __ in [0] * t:
		n = int(input())
		(a, b, c) = map(int, input().split())
		s = list(input())
		p = [0, 0, 0]
		for e in s:
			if e == 'R':
				p[0] += 1
			elif e == 'P':
				p[1] += 1
			elif e == 'S':
				p[2] += 1
		cnt = min(p[2], a) + min(p[1], c) + min(p[0], b)
		if cnt >= (n + 1) // 2:
			print('YES')
			q = [''] * n
			for i in range(n):
				if s[i] == 'R' and b > 0:
					q[i] = 'P'
					b -= 1
				elif s[i] == 'S' and a > 0:
					q[i] = 'R'
					a -= 1
				elif s[i] == 'P' and c > 0:
					q[i] = 'S'
					c -= 1
			for i in range(n):
				if q[i] == '':
					if a > 0:
						q[i] = 'R'
						a -= 1
					elif b > 0:
						q[i] = 'P'
						b -= 1
					else:
						q[i] = 'S'
						c -= 1
			for i in range(n - 1):
				print(q[i], end='')
			print(q[-1])
		else:
			print('NO')
main()


import sys, collections
tc = int(sys.stdin.readline())
for _ in range(tc):
	n = int(sys.stdin.readline())
	(a, b, c) = map(int, sys.stdin.readline().split())
	arr = list(sys.stdin.readline().rstrip())
	res = {'R': a, 'P': b, 'S': c}
	r_win = min(arr.count('S'), res['R'])
	p_win = min(arr.count('R'), res['P'])
	s_win = min(arr.count('P'), res['S'])
	tot = n // 2 + 1 if n % 2 != 0 else n // 2
	if r_win + p_win + s_win >= tot:
		print('YES')
		ans = [''] * n
		for i in range(n):
			if arr[i] == 'R':
				if res['P'] > 0:
					ans[i] = 'P'
					res['P'] -= 1
			elif arr[i] == 'P':
				if res['S'] > 0:
					ans[i] = 'S'
					res['S'] -= 1
			elif res['R'] > 0:
				ans[i] = 'R'
				res['R'] -= 1
		for i in range(n):
			if ans[i] == '':
				if res['P'] > 0:
					ans[i] = 'P'
					res['P'] -= 1
				elif res['R'] > 0:
					ans[i] = 'R'
					res['R'] -= 1
				elif res['S'] > 0:
					ans[i] = 'S'
					res['S'] -= 1
		print(''.join(ans))
	else:
		print('NO')


import sys
readline = sys.stdin.readline
rdw = lambda : readline().rstrip()
rdws = lambda : readline().split()
rdwl = lambda : list(readline().split())
rdi = lambda : int(readline())
rdis = lambda : map(int, readline().split())
rdil = lambda : list(map(int, readline().split()))
rdilrows = lambda cnt: [rdil() for _ in range(cnt)]

def solve():
	Ok = True
	cnt = 0
	n = rdi()
	(a, b, c) = rdis()
	s = rdw()
	res = []
	for si in s:
		h = '-'
		if si == 'R':
			if b > 0:
				b -= 1
				cnt += 1
				h = 'P'
		elif si == 'P':
			if c > 0:
				c -= 1
				cnt += 1
				h = 'S'
		elif a > 0:
			a -= 1
			cnt += 1
			h = 'R'
		res.append(h)
	Ok = cnt >= (n + 1) // 2
	print('YES' if Ok else 'NO')
	if Ok:
		for i in range(n):
			if res[i] == '-':
				if a > 0:
					a -= 1
					res[i] = 'R'
				elif b > 0:
					b -= 1
					res[i] = 'P'
				else:
					res[i] = 'S'
		print(''.join(res))
tests = 1
tests = rdi()
for testnum in range(tests):
	solve()


from math import ceil

def natural():
	if d['S'] > 0:
		return 'S'
	if d['P'] > 0:
		return 'P'
	if d['R'] > 0:
		return 'R'

def beat(s):
	if s == 'P':
		return 'S'
	if s == 'R':
		return 'P'
	if s == 'S':
		return 'R'
q = int(input())
for _ in range(q):
	n = int(input())
	d = {'R': 0, 'S': 0, 'P': 0}
	(R, P, S) = [int(i) for i in input().split()]
	d['R'] = R
	d['S'] = S
	d['P'] = P
	w = 0
	s = input()
	ans = ['' for i in range(len(s))]
	for i in range(len(s)):
		if d[beat(s[i])] > 0:
			ans[i] = 'W'
			w += 1
		else:
			ans[i] = 'L'
		d[beat(s[i])] -= 1
	if w >= ceil(n / 2):
		print('YES')
	else:
		print('NO')
		continue
	for i in range(len(ans)):
		if ans[i] == 'W':
			print(beat(s[i]), end='')
		else:
			n = natural()
			print(n, end='')
			d[n] -= 1
	print()


from math import floor
n_rounds = int(input())
for j in range(n_rounds):
	n = int(input())
	n_opts = [int(m) for m in input().split(' ')]
	bob = input()
	resp = []
	lose = 0
	for i in range(len(bob)):
		if bob[i] == 'R':
			if n_opts[1] > 0:
				n_opts[1] -= 1
				resp.append('P')
			else:
				lose += 1
				resp.append('?')
		elif bob[i] == 'P':
			if n_opts[2] > 0:
				n_opts[2] -= 1
				resp.append('S')
			else:
				lose += 1
				resp.append('?')
		elif n_opts[0] > 0:
			n_opts[0] -= 1
			resp.append('R')
		else:
			lose += 1
			resp.append('?')
	if lose > floor(n / 2):
		print('NO')
	else:
		for i in range(len(resp)):
			if resp[i] == '?':
				if n_opts[0] > 0:
					resp[i] = 'R'
					n_opts[0] -= 1
				elif n_opts[1] > 0:
					resp[i] = 'P'
					n_opts[1] -= 1
				else:
					resp[i] = 'S'
					n_opts[2] -= 1
		print('YES')
		print(''.join(resp))


_ = int(input())
for j in range(_):
	n = int(input())
	(a, b, c) = list(map(int, input().split()))
	st = input()
	l = [0, 0, 0]
	for i in range(n):
		if st[i] == 'R':
			l[0] += 1
		elif st[i] == 'P':
			l[1] += 1
		else:
			l[2] += 1
	wins = min(a, l[2]) + min(b, l[0]) + min(c, l[1])
	if 2 * wins >= n:
		new = ''
		print('YES')
		for i in range(n):
			if st[i] == 'R' and b > 0:
				new += 'P'
				b -= 1
			elif st[i] == 'P' and c > 0:
				new += 'S'
				c -= 1
			elif st[i] == 'S' and a > 0:
				new += 'R'
				a -= 1
			else:
				new += '_'
		for i in range(n):
			if new[i] == '_':
				if a > 0:
					new = new[:i] + 'R' + new[i + 1:]
					a -= 1
				elif b > 0:
					new = new[:i] + 'P' + new[i + 1:]
					b -= 1
				else:
					new = new[:i] + 'S' + new[i + 1:]
					c -= 1
		print(new)
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	(a, b, c) = [int(x) for x in input().split()]
	s = input()
	ans = [None for _ in range(n)]
	leftOvers = []
	winCnts = 0
	for i in range(n):
		if s[i] == 'R':
			if b > 0:
				b -= 1
				ans[i] = 'P'
				winCnts += 1
			else:
				leftOvers.append(i)
		elif s[i] == 'P':
			if c > 0:
				c -= 1
				ans[i] = 'S'
				winCnts += 1
			else:
				leftOvers.append(i)
		elif a > 0:
			a -= 1
			ans[i] = 'R'
			winCnts += 1
		else:
			leftOvers.append(i)
	if winCnts * 2 >= n:
		print('Yes')
		for i in leftOvers:
			if a > 0:
				ans[i] = 'R'
				a -= 1
			elif b > 0:
				ans[i] = 'P'
				b -= 1
			else:
				ans[i] = 'S'
		print(''.join(ans))
	else:
		print('No')


t = int(input())
for i in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	l = input()
	w = 0
	ans = ''
	ans1 = ''
	for j in range(n):
		if l[j] == 'R' and b > 0:
			b -= 1
			w += 1
			ans += 'P'
		elif l[j] == 'P' and c > 0:
			c -= 1
			w += 1
			ans += 'S'
		elif l[j] == 'S' and a > 0:
			a -= 1
			w += 1
			ans += 'R'
		else:
			ans += '_'
	if w >= n // 2 + n % 2:
		print('YES')
		for i in range(n):
			if ans[i] == '_':
				if a > 0:
					ans1 += 'R'
					a -= 1
				elif b > 0:
					ans1 += 'P'
					b -= 1
				else:
					ans1 += 'S'
					c -= 1
			else:
				ans1 += ans[i]
		print(ans1)
	else:
		print('NO')


import math
t = int(input())
for i2 in range(t):
	n = int(input())
	x = list(map(int, input().split()))
	y = str(input())
	ans = [0] * 100000
	for i in range(n):
		if y[i] == 'R':
			if x[1] > 0:
				ans[i] = 2
				x[1] -= 1
		elif y[i] == 'P':
			if x[2] > 0:
				ans[i] = 3
				x[2] -= 1
		elif x[0] > 0:
			ans[i] = 1
			x[0] -= 1
	if n - (x[0] + x[1] + x[2]) < math.ceil(n / 2):
		print('NO', end='')
	else:
		print('YES')
		for i in range(n):
			if ans[i] == 1:
				print('R', end='')
			elif ans[i] == 2:
				print('P', end='')
			elif ans[i] == 3:
				print('S', end='')
			elif x[0] > 0:
				print('R', end='')
				x[0] -= 1
			elif x[1] > 0:
				print('P', end='')
				x[1] -= 1
			else:
				print('S', end='')
	print('')


t = int(input())
for _ in range(t):
	n = int(input())
	(r, p, s) = map(int, input().split())
	bob = input()
	sq = ['X'] * n
	sc = 0
	for (c, x) in enumerate(bob):
		if x == 'R' and p:
			p -= 1
			sq[c] = 'P'
			sc += 1
		elif x == 'P' and s:
			s -= 1
			sq[c] = 'S'
			sc += 1
		elif x == 'S' and r:
			r -= 1
			sq[c] = 'R'
			sc += 1
	if sc < n / 2:
		print('NO')
	else:
		print('YES')
		for (c, x) in enumerate(sq):
			if x == 'X':
				if r:
					r -= 1
					sq[c] = 'R'
				elif s:
					s -= 1
					sq[c] = 'S'
				elif p:
					p -= 1
					sq[c] = 'P'
		print(''.join(sq))


t = int(input())
for i in range(t):
	n = int(input())
	(r, p, s) = map(int, input().split())
	sequence = input()
	R = sequence.count('R')
	P = sequence.count('P')
	S = sequence.count('S')
	sequence = sequence.replace('R', 'a')
	sequence = sequence.replace('P', 'b')
	sequence = sequence.replace('S', 'c')
	if R > p:
		win_p = p
	else:
		win_p = R
	if P > s:
		win_s = s
	else:
		win_s = P
	if S > r:
		win_r = r
	else:
		win_r = S
	wins = win_p + win_s + win_r
	if wins >= n / 2:
		print('YES')
		winsequence = sequence.replace('a', 'P', p)
		winsequence = winsequence.replace('b', 'S', s)
		winsequence = winsequence.replace('c', 'R', r)
		num_r = r - winsequence.count('R')
		num_p = p - winsequence.count('P')
		num_s = s - winsequence.count('S')
		winsequence = winsequence.replace('a', 'R', num_r)
		winsequence = winsequence.replace('a', 'P', num_p)
		winsequence = winsequence.replace('a', 'S', num_s)
		num_r = r - winsequence.count('R')
		num_p = p - winsequence.count('P')
		num_s = s - winsequence.count('S')
		winsequence = winsequence.replace('b', 'R', num_r)
		winsequence = winsequence.replace('b', 'P', num_p)
		winsequence = winsequence.replace('b', 'S', num_s)
		num_r = r - winsequence.count('R')
		num_p = p - winsequence.count('P')
		num_s = s - winsequence.count('S')
		winsequence = winsequence.replace('c', 'R', num_r)
		winsequence = winsequence.replace('c', 'P', num_p)
		winsequence = winsequence.replace('c', 'S', num_s)
		print(winsequence)
	else:
		print('NO')


m = int(input())
for k in range(m):
	n = int(input())
	(a, b, c) = map(int, input().split())
	(A, B, C) = (0, 0, 0)
	s = str(input())
	for k in range(n):
		if s[k] == 'R':
			A += 1
		if s[k] == 'P':
			B += 1
		if s[k] == 'S':
			C += 1
	VinA = min(a, C)
	VinB = min(b, A)
	VinC = min(c, B)
	Vin = VinA + VinB + VinC
	if Vin >= (n - 1) // 2 + 1:
		print('Yes')
		t = ['N'] * n
		for k in range(n):
			if s[k] == 'S' and a > 0:
				t[k] = 'R'
				a -= 1
			if s[k] == 'R' and b > 0:
				t[k] = 'P'
				b = b - 1
			if s[k] == 'P' and c > 0:
				t[k] = 'S'
				c = c - 1
		for k in range(n):
			if t[k] == 'N':
				if a > 0:
					(t[k], a) = ('R', a - 1)
				elif b > 0:
					(t[k], b) = ('P', b - 1)
				elif c > 0:
					t[k] = 'S'
					c -= 1
		s = ''
		for k in range(len(t)):
			s += t[k]
		print(s)
	else:
		print('No')


for i in range(int(input())):
	q = int(input())
	(a, b, c) = map(int, input().split())
	w = list(input())
	r = 0
	p = 0
	s = 0
	for i in w:
		if i == 'R':
			r += 1
		elif i == 'P':
			p += 1
		elif i == 'S':
			s += 1
	n = a + b + c
	if n % 2 == 0:
		n = n // 2
	else:
		n = n // 2 + 1
	P = min(b, r)
	S = min(c, p)
	R = min(a, s)
	a = a - R
	b = b - P
	c = c - S
	if P + S + R < n:
		print('no')
	else:
		print('yes')
		for i in range(q):
			if w[i] == 'R' and P > 0:
				w[i] = 'P'
				P -= 1
			elif w[i] == 'P' and S > 0:
				w[i] = 'S'
				S -= 1
			elif w[i] == 'S' and R > 0:
				w[i] = 'R'
				R -= 1
			elif a > 0:
				w[i] = 'R'
				a -= 1
			elif b > 0:
				w[i] = 'P'
				b -= 1
			elif c > 0:
				w[i] = 'S'
				c -= 1
		print(''.join(w))


import math
t = int(input())
for i in range(t):
	n = int(input())
	(r, p, s) = [int(x) for x in input().split()]
	res = []
	st = input()
	wins = 0
	for c in st:
		if c == 'R':
			if p > 0:
				p -= 1
				res.append('P')
				wins += 1
			else:
				res.append('?')
		if c == 'P':
			if s > 0:
				s -= 1
				res.append('S')
				wins += 1
			else:
				res.append('?')
		if c == 'S':
			if r > 0:
				r -= 1
				res.append('R')
				wins += 1
			else:
				res.append('?')
	if wins >= math.ceil(float(n) / 2):
		print('YES')
		for c in res:
			if c != '?':
				print(c, end='')
			elif r > 0:
				print('R', end='')
				r -= 1
			elif p > 0:
				print('P', end='')
				p -= 1
			elif s > 0:
				print('S', end='')
				s -= 1
		print()
	else:
		print('NO')


from sys import stdin, stdout
from math import ceil
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	(r, p, s) = list(map(int, stdin.readline().split()))
	ss = input()
	win = 0
	ans = [' '] * n
	d = {ch: [] for ch in 'RPS'}
	for i in range(n):
		d[ss[i]] += [i]
	for ind in d['S']:
		if r <= 0:
			break
		ans[ind] = 'R'
		r -= 1
		win += 1
	for ind in d['R']:
		if p <= 0:
			break
		ans[ind] = 'P'
		p -= 1
		win += 1
	for ind in d['P']:
		if s <= 0:
			break
		ans[ind] = 'S'
		s -= 1
		win += 1
	if win >= ceil(n / 2):
		for i in range(n):
			if ans[i] == ' ':
				if r > 0:
					ans[i] = 'R'
					r -= 1
				elif s > 0:
					ans[i] = 'S'
					s -= 1
				elif p > 0:
					ans[i] = 'P'
					p -= 1
		print('YES')
		print(''.join(ans))
	else:
		print('NO')


from math import ceil, floor
t = int(input())
while t:
	n = int(input())
	l = list(map(int, input().split()))
	st = input()
	r = st.count('R')
	p = st.count('P')
	s = st.count('S')
	ext = []
	su = min(s, l[0])
	ext.append(l[0] - s)
	su += min(r, l[1])
	ext.append(l[1] - r)
	su += min(p, l[2])
	ext.append(l[2] - p)
	if ceil(n / 2) - n / 2 == n / 2 - floor(n / 2) or ceil(n / 2) - n / 2 < n / 2 - floor(n / 2):
		val = ceil(n / 2)
	else:
		val = floor(n / 2)
	if val > su:
		print('NO')
	else:
		print('YES')
		for i in range(len(st)):
			if st[i] == 'P' and l[2] != 0:
				print('S', end='')
				l[2] -= 1
			elif st[i] == 'P' and l[2] == 0:
				if ext[0] > 0:
					print('R', end='')
					ext[0] -= 1
				elif ext[1] > 0:
					print('P', end='')
					ext[1] -= 1
				elif ext[2] > 0:
					print('S', end='')
					ext[2] -= 1
			elif st[i] == 'S' and l[0] != 0:
				print('R', end='')
				l[0] -= 1
			elif st[i] == 'S' and l[0] == 0:
				if ext[0] > 0:
					print('R', end='')
					ext[0] -= 1
				elif ext[1] > 0:
					print('P', end='')
					ext[1] -= 1
				elif ext[2] > 0:
					print('S', end='')
					ext[2] -= 1
			elif st[i] == 'R' and l[1] != 0:
				print('P', end='')
				l[1] -= 1
			elif st[i] == 'R' and l[1] == 0:
				if ext[0] > 0:
					print('R', end='')
					ext[0] -= 1
				elif ext[1] > 0:
					print('P', end='')
					ext[1] -= 1
				elif ext[2] > 0:
					print('S', end='')
					ext[2] -= 1
		print()
	t -= 1


def rps(n, r, p, s, st):
	(a, k) = ('', 0)
	for i in st:
		if i == 'R':
			if p:
				(p, a, k) = (p - 1, a + 'P', k + 1)
			else:
				a += '@'
		elif i == 'P':
			if s:
				(s, a, k) = (s - 1, a + 'S', k + 1)
			else:
				a += '@'
		elif r:
			(r, a, k) = (r - 1, a + 'R', k + 1)
		else:
			a += '@'
	if k < n // 2 + n % 2:
		return 'NO'
	else:
		for i in range(n):
			if a[i] == '@':
				if r:
					a = a[:i] + 'R' + a[i + 1:]
					r -= 1
				elif p:
					a = a[:i] + 'P' + a[i + 1:]
					p -= 1
				else:
					a = a[:i] + 'S' + a[i + 1:]
					s -= 1
		print('YES')
		return a
for j in range(int(input())):
	n = int(input())
	(r, p, s) = map(int, input().split())
	st = str(input())
	print(rps(n, r, p, s, st))


from math import ceil
for _ in range(int(input())):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	d = {'R': 0, 'P': 0, 'S': 0}
	for i in s:
		d[i] += 1
	wins = min(b, d['R']) + min(d['P'], c) + min(d['S'], a)
	if wins >= ceil(n / 2):
		print('YES')
		ans = [''] * n
		for i in range(n):
			if s[i] == 'R' and b > 0:
				ans[i] = 'P'
				b -= 1
			elif s[i] == 'P' and c > 0:
				ans[i] = 'S'
				c -= 1
			elif s[i] == 'S' and a > 0:
				ans[i] = 'R'
				a -= 1
		for i in range(n):
			if a + b + c == 0:
				break
			if ans[i] == '':
				if a != 0:
					ans[i] = 'R'
					a -= 1
				elif b != 0:
					ans[i] = 'P'
					b -= 1
				elif c != 0:
					ans[i] = 'S'
					c -= 1
		out = ''
		for an in ans:
			out += an
		print(out)
	else:
		print('NO')


from collections import Counter
from math import ceil

def run_testcase():
	n = int(input())
	[a, b, c] = [int(x) for x in input().split()]
	moves = input()
	moves_count = Counter(moves)
	min_wins = ceil(n / 2)
	wins = 0
	wins += min(b, moves_count['R'])
	wins += min(c, moves_count['P'])
	wins += min(a, moves_count['S'])
	if wins < min_wins:
		print('NO')
		return
	a_left = a - min(a, moves_count['S'])
	b_left = b - min(b, moves_count['R'])
	c_left = c - min(c, moves_count['P'])
	winning_moves = ''
	for move in moves:
		if move == 'R':
			if b > 0:
				winning_moves += 'P'
				b -= 1
			elif c_left > 0:
				winning_moves += 'S'
				c_left -= 1
			elif a_left > 0:
				winning_moves += 'R'
				a_left -= 1
		if move == 'P':
			if c > 0:
				winning_moves += 'S'
				c -= 1
			elif b_left > 0:
				winning_moves += 'P'
				b_left -= 1
			elif a_left > 0:
				winning_moves += 'R'
				a_left -= 1
		if move == 'S':
			if a > 0:
				winning_moves += 'R'
				a -= 1
			elif b_left > 0:
				winning_moves += 'P'
				b_left -= 1
			elif c_left > 0:
				winning_moves += 'S'
				c_left -= 1
	print('YES')
	print(winning_moves)
testcase_count = int(input())
for i in range(testcase_count):
	run_testcase()


for _ in range(int(input())):
	n = int(input())
	(r, p, s) = map(int, input().split())
	st = input()
	rc = st.count('R')
	sc = st.count('S')
	pc = st.count('P')
	v = min(rc, p) + min(sc, r) + min(pc, s)
	if 2 * v < n:
		print('NO')
	else:
		ans = []
		print('YES')
		for e in st:
			if e == 'S' and r > 0:
				ans.append('R')
				r -= 1
			elif e == 'R' and p > 0:
				ans.append('P')
				p -= 1
			elif e == 'P' and s > 0:
				ans.append('S')
				s -= 1
			else:
				ans.append('-')
		for i in range(n):
			if ans[i] == '-':
				if r > 0:
					ans[i] = 'R'
					r -= 1
				elif s > 0:
					ans[i] = 'S'
					s -= 1
				elif p > 0:
					ans[i] = 'P'
					p -= 1
		print(''.join(ans))


from math import ceil
for _ in range(int(input())):
	n = int(input())
	(r, p, s) = map(int, input().split())
	moves = input()
	ans = ['#'] * n
	ind = 0
	for ch in moves:
		if ch is 'R' and p > 0:
			p -= 1
			ans[ind] = 'P'
		if ch is 'P' and s > 0:
			s -= 1
			ans[ind] = 'S'
		if ch is 'S' and r > 0:
			r -= 1
			ans[ind] = 'R'
		ind += 1
	for i in range(n):
		if ans[i] is '#':
			if r > 0:
				ans[i] = 'R'
				r -= 1
			elif p > 0:
				ans[i] = 'P'
				p -= 1
			elif s > 0:
				ans[i] = 'S'
				s -= 1
	wins = 0
	for i in range(n):
		if moves[i] is 'R' and ans[i] is 'P':
			wins += 1
		if moves[i] is 'P' and ans[i] is 'S':
			wins += 1
		if moves[i] is 'S' and ans[i] is 'R':
			wins += 1
	if wins >= int(ceil(n / 2)):
		print('YES')
		print(''.join(ans))
	else:
		print('NO')


from math import ceil
from collections import Counter
for i in range(int(input())):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	con = Counter(s)
	R = con['R']
	P = con['P']
	S = con['S']
	win = min(R, b)
	win += min(P, c)
	win += min(S, a)
	if win >= ceil(n / 2):
		print('YES')
		s = s.replace('R', 'p', min(R, b))
		s = s.replace('P', 's', min(P, c))
		s = s.replace('S', 'r', min(S, a))
		b -= min(R, b)
		c -= min(P, c)
		a -= min(S, a)
		t = ''
		for j in s:
			if j.isupper():
				if b > 0:
					t += 'P'
					b -= 1
				elif c > 0:
					t += 'S'
					c -= 1
				else:
					t += 'R'
					a -= 1
			else:
				t += j.upper()
		print(t)
	else:
		print('NO')


import math
t = int(input())
for _ in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	d = {'R': 'P', 'P': 'S', 'S': 'R'}
	av = {'R': a, 'P': b, 'S': c}
	s = input()
	r = {'R': 0, 'P': 0, 'S': 0}
	for i in s:
		r[i] += 1
	x = 0
	for i in r:
		x += min(r[i], av[d[i]])
	if x >= math.ceil(n / 2):
		print('YES')
		ans = [0] * n
		for i in range(n):
			if av[d[s[i]]] > 0:
				ans[i] = d[s[i]]
				av[d[s[i]]] -= 1
		dp = []
		for i in av:
			while av[i] != 0:
				dp.append(i)
				av[i] -= 1
		for i in range(n):
			if ans[i] == 0:
				ans[i] = dp.pop(0)
		print(''.join(ans))
	else:
		print('NO')


dict = {'r': 'p', 'p': 's', 's': 'r'}

def okrug(x):
	x1 = x // 2
	if x % 2 != 0:
		x1 += 1
	return x1
t = int(input())
for i in range(t):
	n = int(input())
	n1 = okrug(n)
	(a, b, c) = [int(i) for i in input().split()]
	sti = input().lower()
	(r, p, s) = (0, 0, 0)
	for k in sti:
		if dict[k] == 'r':
			r += 1
		if dict[k] == 'p':
			p += 1
		if dict[k] == 's':
			s += 1
	wins = 0
	if r <= a:
		wins += r
	else:
		wins += a
	if p <= b:
		wins += p
	else:
		wins += b
	if s <= c:
		wins += s
	else:
		wins += c
	if wins >= n1:
		print('YES')
		ans = ''
		for k in sti:
			if dict[k] == 'r':
				if a > 0:
					ans += 'R'
					a -= 1
				else:
					ans += '0'
			if dict[k] == 'p':
				if b > 0:
					ans += 'P'
					b -= 1
				else:
					ans += '0'
			if dict[k] == 's':
				if c > 0:
					ans += 'S'
					c -= 1
				else:
					ans += '0'
		ans1 = ''
		for k in ans:
			if k != '0':
				ans1 += k
			elif a > 0:
				ans1 += 'R'
				a -= 1
			elif b > 0:
				ans1 += 'P'
				b -= 1
			elif c > 0:
				ans1 += 'S'
				c -= 1
		print(ans1)
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	S = str(input())
	B = 0
	A = 0
	C = 0
	f = [0] * n
	for i in range(n):
		if S[i] == 'R':
			B += 1
			if B <= b:
				f[i] = 'P'
		elif S[i] == 'P':
			C += 1
			if C <= c:
				f[i] = 'S'
		else:
			A += 1
			if A <= a:
				f[i] = 'R'
	if A > a:
		A = a
	if B > b:
		B = b
	if C > c:
		C = c
	if A + B + C < (n + 1) // 2:
		print('no')
	else:
		print('yes')
		for i in range(n):
			if f[i] == 0:
				if c - C > 0:
					f[i] = 'S'
					c -= 1
				elif b - B > 0:
					f[i] = 'P'
					b -= 1
				else:
					f[i] = 'R'
			if i != n - 1:
				print(f[i], end='')
			else:
				print(f[i])


from math import *
t = int(input())
for i in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	m = dict(zip(['R', 'P', 'S'], ['P', 'S', 'R']))
	ans = []
	for j in range(n):
		w = m[s[j]]
		if w == 'R' and a > 0:
			a -= 1
			ans.append(w)
		elif w == 'P' and b > 0:
			b -= 1
			ans.append(w)
		elif w == 'S' and c > 0:
			c -= 1
			ans.append(w)
		else:
			ans.append('')
	if ceil(n / 2) > n - a - b - c:
		print('NO')
	else:
		print('YES')
		for j in ans:
			if j:
				print(j, end='')
			elif a > 0:
				a -= 1
				print('R', end='')
			elif b > 0:
				b -= 1
				print('P', end='')
			elif c > 0:
				c -= 1
				print('S', end='')
		print('')


import math

def solve(s, a, b, c):
	n = len(s)
	win = math.ceil(n / 2)
	ans = [0] * n
	for i in range(n):
		if s[i] == 'S' and a > 0:
			a -= 1
			ans[i] = 'R'
			win -= 1
	for i in range(n):
		if s[i] == 'R' and b > 0:
			b -= 1
			ans[i] = 'P'
			win -= 1
	for i in range(n):
		if s[i] == 'P' and c > 0:
			c -= 1
			ans[i] = 'S'
			win -= 1
	for i in range(n):
		if ans[i] == 0:
			if a > 0:
				ans[i] = 'R'
				a -= 1
			elif b > 0:
				ans[i] = 'P'
				b -= 1
			else:
				ans[i] = 'S'
				c -= 1
	if win > 0:
		print('NO')
		return
	print('YES')
	for i in ans:
		print(i, end='')
	print()

def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		(a, b, c) = map(int, input().split())
		s = input()
		solve(s, a, b, c)
main()


for _ in range(int(input())):
	n = int(input())
	rps = [int(x) for x in input().split()]
	s = input()
	cnt = 0
	t = []
	temp = []
	for x in s:
		flag = 0
		if x == 'R':
			if rps[1] > 0:
				rps[1] -= 1
				cnt += 1
				t.append('P')
				flag = 1
		elif x == 'P':
			if rps[2] > 0:
				rps[2] -= 1
				cnt += 1
				t.append('S')
				flag = 1
		elif rps[0] > 0:
			rps[0] -= 1
			cnt += 1
			t.append('R')
			flag = 1
		if flag == 0:
			t.append('_')
	for x in range(rps[0]):
		temp.append('R')
	for x in range(rps[1]):
		temp.append('P')
	for x in range(rps[2]):
		temp.append('S')
	if (n + 1) // 2 <= cnt:
		print('YES')
		for x in range(n):
			if t[x] == '_':
				t[x] = temp[0]
				temp.pop(0)
		print(''.join(t))
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	if min(s.count('R'), b) + min(s.count('P'), c) + min(s.count('S'), a) >= n // 2 + n % 2:
		print('YES')
		ans = []
		anss = ''
		for i in range(n):
			if s[i] == 'R' and b > 0:
				ans.append('P')
				b -= 1
			elif s[i] == 'P' and c > 0:
				ans.append('S')
				c -= 1
			elif s[i] == 'S' and a > 0:
				ans.append('R')
				a -= 1
			else:
				ans.append('#')
		for i in range(n):
			if ans[i] == '#':
				if a > 0:
					anss += 'R'
					a -= 1
				elif b > 0:
					anss += 'P'
					b -= 1
				else:
					anss += 'S'
					c -= 1
			else:
				anss += ans[i]
		print(anss)
	else:
		print('NO')


from math import *
n = int(input())
for i in range(n):
	l = int(input())
	c = [int(s) for s in input().split()]
	s = list(input())
	ad = s.copy()
	p = 0
	for i in range(len(s)):
		ad[i] = '?'
		if s[i] == 'R':
			if c[1] > 0:
				c[1] -= 1
				ad[i] = 'P'
				p += 1
		if s[i] == 'P':
			if c[2] > 0:
				c[2] -= 1
				ad[i] = 'S'
				p += 1
		if s[i] == 'S':
			if c[0] > 0:
				c[0] -= 1
				ad[i] = 'R'
				p += 1
	for i in range(len(s)):
		if ad[i] == '?':
			if c[0] > 0:
				ad[i] = 'R'
				c[0] -= 1
				continue
			if c[1] > 0:
				ad[i] = 'P'
				c[1] -= 1
				continue
			if c[2] > 0:
				ad[i] = 'S'
				c[2] -= 1
				continue
	if p >= ceil(l / 2):
		print('yes')
		print(''.join(ad))
	else:
		print('no')


for _ in range(int(input())):
	n = int(input())
	(a, b, c) = list(map(int, input().split()))
	arr = list(map(str, input()))
	ans = [None for i in range(n)]
	for i in range(n):
		if arr[i] == 'R' and b > 0:
			b -= 1
			ans[i] = 'P'
		elif arr[i] == 'P' and c > 0:
			c -= 1
			ans[i] = 'S'
		elif arr[i] == 'S' and a > 0:
			a -= 1
			ans[i] = 'R'
	cnt = ans.count(None)
	t = n - cnt
	for i in range(n):
		if ans[i] == None:
			if a > 0:
				a -= 1
				ans[i] = 'R'
			elif b > 0:
				b -= 1
				ans[i] = 'P'
			elif c > 0:
				c -= 1
				ans[i] = 'S'
	if n % 2 == 0:
		if t >= n // 2:
			print('YES')
			print(''.join((str(x) for x in ans)))
		else:
			print('NO')
	elif t >= 1 + n // 2:
		print('YES')
		print(''.join((str(x) for x in ans)))
	else:
		print('NO')


from math import ceil
t = int(input())
for i in range(0, t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	wins = 0
	A = 0
	B = 0
	C = 0
	for j in s:
		if j == 'R':
			A += 1
		if j == 'P':
			B += 1
		if j == 'S':
			C += 1
	pool = []
	for j in range(0, abs(b - A)):
		if b > A:
			pool.append('P')
			A -= 1
	for j in range(0, abs(c - B)):
		if c > B:
			pool.append('S')
			B -= 1
	for j in range(0, abs(a - C)):
		if a > C:
			pool.append('R')
			a -= 1
	ans = []
	for j in s:
		if j == 'R':
			if b > 0:
				b -= 1
				wins += 1
				ans.append('P')
			else:
				ans.append(pool[len(pool) - 1])
				pool.pop()
		if j == 'P':
			if c > 0:
				c -= 1
				wins += 1
				ans.append('S')
			else:
				ans.append(pool[len(pool) - 1])
				pool.pop()
		if j == 'S':
			if a > 0:
				a -= 1
				wins += 1
				ans.append('R')
			else:
				ans.append(pool[len(pool) - 1])
				pool.pop()
	if wins >= ceil(n / 2):
		print('YES')
		for j in ans:
			print(j, end='')
		print()
	else:
		print('NO')


from math import *
q = int(input())
for i in range(q):
	n = int(input())
	(a, b, c) = map(int, input().split())
	bob = input()
	R = bob.count('R')
	P = bob.count('P')
	S = bob.count('S')
	w = 0
	ans = ''
	for cc in bob:
		if cc == 'R':
			R -= 1
			if b > 0:
				b -= 1
				w += 1
				ans += 'P'
			elif a - S > c - P:
				a -= 1
				ans += 'R'
			else:
				c -= 1
				ans += 'S'
		elif cc == 'P':
			P -= 1
			if c > 0:
				c -= 1
				w += 1
				ans += 'S'
			elif b - R > a - S:
				b -= 1
				ans += 'P'
			else:
				a -= 1
				ans += 'R'
		else:
			S -= 1
			if a > 0:
				a -= 1
				w += 1
				ans += 'R'
			elif b - R > c - P:
				b -= 1
				ans += 'P'
			else:
				c -= 1
				ans += 'S'
	if w * 2 >= n:
		print('YES')
		print(ans)
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	ss = input()
	(r, p, s) = (ss.count('R'), ss.count('P'), ss.count('S'))
	win = min(a, s) + min(b, r) + min(c, p)
	if win < (n + 1) // 2:
		print('NO')
		continue
	print('YES')
	res = ['' for i in range(n)]
	for i in range(n):
		if ss[i] == 'R' and b > 0:
			res[i] = 'P'
			b -= 1
		if ss[i] == 'P' and c > 0:
			res[i] = 'S'
			c -= 1
		if ss[i] == 'S' and a > 0:
			res[i] = 'R'
			a -= 1
	for i in range(n):
		if res[i] == '':
			if a:
				res[i] = 'R'
				a -= 1
			elif b:
				res[i] = 'P'
				b -= 1
			elif c:
				res[i] = 'S'
				c -= 1
	print(''.join(res))


import sys
input = sys.stdin.readline
t = int(input())
for testcases in range(t):
	n = int(input())
	(a, b, c) = list(map(int, input().split()))
	B = input().strip()
	R = B.count('R')
	P = B.count('P')
	S = B.count('S')
	if min(b, R) + min(c, P) + min(a, S) >= n / 2:
		print('YES')
	else:
		print('NO')
		continue
	ANS = [0] * n
	R0 = min(a, S)
	P0 = min(b, R)
	S0 = min(c, P)
	R1 = a - R0
	P1 = b - P0
	S1 = c - S0
	for i in range(n):
		if B[i] == 'S' and R0 > 0:
			ANS[i] = 'R'
			R0 -= 1
		elif B[i] == 'R' and P0 > 0:
			ANS[i] = 'P'
			P0 -= 1
		elif B[i] == 'P' and S0 > 0:
			ANS[i] = 'S'
			S0 -= 1
	for i in range(n):
		if ANS[i] == 0:
			if R1 > 0:
				R1 -= 1
				ANS[i] = 'R'
			elif P1 > 0:
				P1 -= 1
				ANS[i] = 'P'
			else:
				S1 -= 1
				ANS[i] = 'S'
	print(''.join(ANS))


t = int(input())
for _ in range(t):
	n = int(input())
	(r, p, s) = map(int, input().split())
	bob = input()
	w = 0
	h = ''
	for c in bob:
		if 'R' == c and p > 0:
			p -= 1
			w += 1
			h += 'P'
		elif 'P' == c and s > 0:
			s -= 1
			w += 1
			h += 'S'
		elif 'S' == c and r > 0:
			r -= 1
			w += 1
			h += 'R'
		else:
			h += '_'
		if w << 1 >= n:
			h += '_' * (n - len(h))
			break
	if w << 1 >= n:
		print('YES')
		ret = ''
		for c in h:
			if '_' == c:
				if r > 0:
					ret += 'R'
					r -= 1
				elif p > 0:
					ret += 'P'
					p -= 1
				elif s > 0:
					ret += 'S'
					s -= 1
			else:
				ret += c
		print(ret)
	else:
		print('NO')


from math import ceil
for t in range(int(input())):
	n = int(input())
	(r, p, s1) = map(int, input().split())
	s = input()
	d = {}
	d['S'] = 0
	d['P'] = 0
	d['R'] = 0
	for i in s:
		d[i] += 1
	z = 0
	z = z + min(r, d['S'])
	z = z + min(p, d['R'])
	z = z + min(s1, d['P'])
	if z >= ceil(n / 2):
		print('YES')
		l = []
		for i in range(n):
			if s[i] == 'P':
				if s1 > 0:
					l.append('S')
					s1 -= 1
				else:
					l.append('X')
			elif s[i] == 'R':
				if p > 0:
					l.append('P')
					p -= 1
				else:
					l.append('X')
			elif r > 0:
				l.append('R')
				r -= 1
			else:
				l.append('X')
		for i in l:
			if i == 'X':
				if r > 0:
					print('R', end='')
					r -= 1
				elif p > 0:
					print('P', end='')
					p -= 1
				else:
					print('S', end='')
					s1 -= 1
			else:
				print(i, end='')
		print()
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	S = [0] * 3
	for i in range(n):
		if s[i] == 'R':
			S[0] += 1
		elif s[i] == 'P':
			S[1] += 1
		else:
			S[2] += 1
	(aw, bw, cw) = (min(a, S[2]), min(b, S[0]), min(c, S[1]))
	if aw + bw + cw < (n - 1) // 2 + 1:
		print('NO')
	else:
		print('YES')
		ans = ''
		for i in range(n):
			if s[i] == 'R':
				if bw > 0:
					ans += 'P'
					b -= 1
					bw -= 1
				elif a > aw:
					ans += 'R'
					a -= 1
				else:
					ans += 'S'
					c -= 1
			elif s[i] == 'P':
				if cw > 0:
					ans += 'S'
					c -= 1
					cw -= 1
				elif a > aw:
					ans += 'R'
					a -= 1
				else:
					ans += 'P'
					b -= 1
			elif aw > 0:
				ans += 'R'
				a -= 1
				aw -= 1
			elif b > bw:
				ans += 'P'
				b -= 1
			else:
				ans += 'S'
				c -= 1
		print(ans)


t = int(input())
for cases in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	p = ['U'] * n
	ans = ''
	for i in range(n):
		if s[i] == 'R' and b > 0:
			b -= 1
			p[i] = 'P'
		if s[i] == 'P' and c > 0:
			c -= 1
			p[i] = 'S'
		if s[i] == 'S' and a > 0:
			a -= 1
			p[i] = 'R'
	if a + b + c > n // 2:
		print('NO')
		continue
	else:
		print('YES')
		for i in range(n):
			if p[i] == 'U':
				if a > 0:
					a -= 1
					p[i] = 'R'
				elif b > 0:
					b -= 1
					p[i] = 'P'
				elif c > 0:
					c -= 1
					p[i] = 'S'
			print(p[i], end='')
		print('')


t = int(input())
for i in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	l = input()
	ans = [0] * n
	d = 0
	for i in range(n):
		if l[i] == 'R':
			if b:
				b -= 1
				ans[i] = 'P'
				d += 1
	for i in range(n):
		if l[i] == 'P':
			if c:
				c -= 1
				ans[i] = 'S'
				d += 1
	for i in range(n):
		if l[i] == 'S':
			if a:
				a -= 1
				ans[i] = 'R'
				d += 1
	for i in range(n):
		if ans[i] == 0:
			if a:
				a -= 1
				ans[i] = 'R'
			elif b:
				b -= 1
				ans[i] = 'P'
			else:
				c -= 1
				ans[i] = 'S'
	if d < (n + 1) // 2:
		print('NO')
	else:
		print('YES')
		for i in ans:
			print(i, end='')
		print()


import sys
import math as mt
t = int(input())
for __ in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	ans = 0
	rsum = [0] * (len(s) + 2)
	psum = [0] * (len(s) + 2)
	ssum = [0] * (len(s) + 2)
	for i in range(len(s)):
		if s[i] == 'P':
			psum[i + 1] += 1
		if s[i] == 'R':
			rsum[i + 1] += 1
		if s[i] == 'S':
			ssum[i + 1] += 1
		rsum[i + 1] += rsum[i]
		psum[i + 1] += psum[i]
		ssum[i + 1] += ssum[i]
	s1 = ''
	for i in range(len(s)):
		ch = 0
		if s[i] == 'S':
			if s[i] == 'S' and a > 0:
				s1 += 'R'
				a -= 1
				ans += 1
			elif b - (rsum[n] - rsum[i]) >= c - (psum[n] - psum[i]) and b > 0:
				s1 += 'P'
				b -= 1
			else:
				c -= 1
				s1 += 'S'
		if s[i] == 'R':
			if s[i] == 'R' and b > 0:
				b -= 1
				s1 += 'P'
				ans += 1
			elif a - (ssum[n] - ssum[i]) >= c - (psum[n] - psum[i]) and a > 0:
				s1 += 'R'
				a -= 1
			else:
				c -= 1
				s1 += 'S'
		if s[i] == 'P':
			if s[i] == 'P' and c > 0:
				c -= 1
				s1 += 'S'
				ans += 1
			elif b - (rsum[n] - rsum[i]) >= a - (ssum[n] - ssum[i]) and b > 0:
				b -= 1
				s1 += 'P'
			else:
				a -= 1
				s1 += 'R'
	if ans >= mt.ceil(n / 2):
		print('YES')
		print(s1)
	else:
		print('NO')


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input().replace('S', 'r', a).replace('R', 'p', b).replace('P', 's', c)
	if sum((ch.islower() for ch in s)) < (n + 1) // 2:
		print('NO')
	else:
		print('YES')
		C = Counter(s)
		stack = ['R'] * (a - C['r']) + ['P'] * (b - C['p']) + ['S'] * (c - C['s'])
		for ch in s:
			print(stack.pop() if ch.isupper() else ch.upper(), end='')
		print()


T = int(input())
for _ in range(0, T):
	N = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	ct = 0
	ans = ''
	for i in range(0, len(s)):
		if s[i] == 'R':
			if b > 0:
				b -= 1
				ans += 'P'
				ct += 1
			else:
				ans += '.'
		elif s[i] == 'P':
			if c > 0:
				c -= 1
				ans += 'S'
				ct += 1
			else:
				ans += '.'
		elif a > 0:
			a -= 1
			ans += 'R'
			ct += 1
		else:
			ans += '.'
	tg = N // 2
	if N % 2 != 0:
		tg += 1
	if ct >= tg:
		print('YES')
		ans1 = []
		for i in range(0, len(ans)):
			ans1.append(ans[i])
		for i in range(0, len(ans1)):
			if ans1[i] == '.':
				if a > 0:
					ans1[i] = 'R'
					a -= 1
				elif b > 0:
					ans1[i] = 'P'
					b -= 1
				elif c > 0:
					ans1[i] = 'S'
					c -= 1
		fnl = ''.join(ans1)
		print(fnl)
	else:
		print('NO')


import math
r = int(input())
s2i = {'R': 0, 'P': 1, 'S': 2}
i2s = 'PSR'
for _ in range(r):
	n = int(input())
	(a, b, c) = [j for j in map(int, input().split(' '))]
	seq = list(input())
	output = [0] * n
	p = [b, c, a]
	wins = 0
	for (i, s) in enumerate(seq):
		s = s2i[s]
		if p[s] > 0:
			output[i] = i2s[s]
			p[s] -= 1
			wins += 2
	for (i, o) in enumerate(output):
		if o == 0:
			j = 0
			while p[j] == 0:
				j += 1
			output[i] = i2s[j]
			p[j] -= 1
	print(['YES\n' + ''.join(output), 'NO'][wins < n])


import os
import sys
from io import BytesIO, IOBase

def main():
	for _ in range(int(input())):
		n = int(input())
		(a, b, c) = map(int, input().split())
		s = input().rstrip()
		d = {'R': 'P', 'P': 'S', 'S': 'R'}
		e = {'R': a, 'P': b, 'S': c}
		(ans, z) = (['0'] * n, 0)
		for i in range(n):
			if e[d[s[i]]]:
				ans[i] = d[s[i]]
				e[d[s[i]]] -= 1
				z += 1
		if z >= (n + 1) // 2:
			print('YES')
			for i in range(n):
				if ans[i] == '0':
					for j in e:
						if e[j]:
							ans[i] = j
							e[j] -= 1
							break
			print(*ans, sep='')
		else:
			print('NO')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for i in range(int(input())):
	n = int(input())
	w = 0
	m = ''
	(r, p, s) = map(int, input().split())
	e = ''
	x = input()
	(r1, p1, s1) = (x.count('R'), x.count('P'), x.count('S'))
	if r > s1:
		e += 'R' * (r - s1)
	if p > r1:
		e += 'P' * (p - r1)
	if s > p1:
		e += 'S' * (s - p1)
	for i in x:
		if i == 'R':
			if p:
				w += 1
				p -= 1
				m += 'P'
			else:
				m += e[:1]
				e = e[1:]
		if i == 'P':
			if s:
				w += 1
				s -= 1
				m += 'S'
			else:
				m += e[:1]
				e = e[1:]
		if i == 'S':
			if r:
				w += 1
				r -= 1
				m += 'R'
			else:
				m += e[:1]
				e = e[1:]
	if w >= (n + 1) // 2:
		print('YES', '\n', m, sep='')
	else:
		print('NO')


for i in range(int(input())):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	(x, y, z) = (0, 0, 0)
	for i in s:
		if i == 'R':
			x += 1
		elif i == 'P':
			y += 1
		else:
			z += 1
	r = min(x, b) + min(y, c) + min(z, a)
	if (n + 1) // 2 <= r:
		print('YES')
		q = ''
		for i in s:
			if i == 'R' and b > 0:
				q += 'P'
				b -= 1
			elif i == 'P' and c > 0:
				q += 'S'
				c -= 1
			elif i == 'S' and a > 0:
				q += 'R'
				a -= 1
			else:
				q += '?'
		l = [a, b, c, 'R', 'P', 'S']
		for j in range(3):
			while l[j]:
				q = q.replace('?', l[j + 3], 1)
				l[j] -= 1
		print(q)
	else:
		print('NO')


from math import gcd
for _ in range(int(input())):
	n = int(input())
	(r, p, s) = map(int, input().split())
	s1 = input()
	ans = 0
	ans1 = ''
	for i in s1:
		if i == 'R':
			if p > 0:
				ans += 1
				p = p - 1
				ans1 = ans1 + 'P'
			else:
				ans1 = ans1 + 'X'
		if i == 'P':
			if s > 0:
				ans += 1
				s = s - 1
				ans1 = ans1 + 'S'
			else:
				ans1 = ans1 + 'X'
		if i == 'S':
			if r > 0:
				ans += 1
				r = r - 1
				ans1 = ans1 + 'R'
			else:
				ans1 = ans1 + 'X'
	if n % 2 == 0:
		n1 = n // 2
	else:
		n1 = n // 2 + 1
	if ans >= n1:
		ans1 = list(ans1)
		print('YES')
		for i in range(len(ans1)):
			if ans1[i] == 'X':
				if p > 0:
					ans1[i] = 'P'
					p = p - 1
				elif s > 0:
					ans1[i] = 'S'
					s = s - 1
				else:
					ans1[i] = 'R'
					r = r - 1
		print(''.join(ans1))
	else:
		print('NO')


import math
import collections

def solve(n, a, b, c, s):
	wins = min(a, s.count('S')) + min(b, s.count('R')) + min(c, s.count('P'))
	comb = [''] * n
	for i in range(n):
		if s[i] == 'S':
			if a > 0:
				comb[i] = 'R'
				a -= 1
		if s[i] == 'R':
			if b > 0:
				comb[i] = 'P'
				b -= 1
		if s[i] == 'P':
			if c > 0:
				comb[i] = 'S'
				c -= 1
	for i in range(n):
		if comb[i] == '':
			if a > 0:
				comb[i] = 'R'
				a -= 1
			elif b > 0:
				comb[i] = 'P'
				b -= 1
			elif c > 0:
				comb[i] = 'S'
				c -= 1
	if wins >= (n + 1) // 2:
		return 'YES' + '\n' + ''.join(comb)
	else:
		return 'NO'
t = int(input())
for t in range(t):
	n = int(input())
	(a, b, c) = [int(s) for s in input().split()]
	s = input()
	result = solve(n, a, b, c, s)
	print(result)


from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	(a, b, c) = list(map(int, input().split()))
	s = list(input())
	res = [-1 for i in range(n)]
	check = n // 2
	i = 0
	while i < n:
		if s[i] == 'S' and a > 0:
			a -= 1
			res[i] = 'R'
		elif s[i] == 'R' and b > 0:
			b -= 1
			res[i] = 'P'
		elif s[i] == 'P' and c > 0:
			c -= 1
			res[i] = 'S'
		i += 1
	win = n - res.count(-1)
	for i in range(n):
		if res[i] == -1:
			if a > 0:
				a -= 1
				res[i] = 'R'
			elif b > 0:
				b -= 1
				res[i] = 'P'
			elif c > 0:
				c -= 1
				res[i] = 'S'
	if n % 2 == 0:
		if win >= check:
			print('YES')
			print(''.join((str(i) for i in res)))
		else:
			print('No')
	elif win >= 1 + check:
		print('yes')
		print(''.join((str(i) for i in res)))
	else:
		print('no')


t = int(input())
for _ in range(t):
	n = int(input())
	(r, p, s) = map(int, input().split())
	S = input()
	ans = [None] * n
	win = 0
	for (i, c) in enumerate(S):
		if c == 'R' and p > 0:
			ans[i] = 'P'
			p -= 1
			win += 1
		elif c == 'P' and s > 0:
			ans[i] = 'S'
			s -= 1
			win += 1
		elif c == 'S' and r > 0:
			ans[i] = 'R'
			r -= 1
			win += 1
	for i in range(n):
		if ans[i] is None:
			if r > 0:
				ans[i] = 'R'
				r -= 1
			elif p > 0:
				ans[i] = 'P'
				p -= 1
			else:
				ans[i] = 'S'
				s -= 1
	if win >= (n + 1) // 2:
		print('YES')
		print(*ans, sep='')
	else:
		print('NO')


import sys
import math
GAME = {'R': 'P', 'P': 'S', 'S': 'R'}

def read_ints():
	return (int(x) for x in sys.stdin.readline().split())
(t,) = read_ints()
for _ in range(t):
	(n,) = read_ints()
	left = {}
	(left['R'], left['P'], left['S']) = read_ints()
	(wins, strat) = (0, [])
	for c in sys.stdin.readline()[:n]:
		ans = GAME[c]
		if left[ans] > 0:
			left[ans] -= 1
			strat.append(ans)
			wins += 1
		else:
			strat.append('*')
	if wins < math.ceil(n / 2):
		sys.stdout.write('NO\n')
		continue
	for (i, c) in enumerate(strat):
		if c == '*':
			for (k, v) in left.items():
				if v > 0:
					strat[i] = k
					left[k] -= 1
					break
	sys.stdout.write('YES\n' + ''.join(strat) + '\n')


import math
n = int(input())
for z in range(n):
	nc = int(input())
	(r1, p1, s1) = map(int, input().split())
	won = False
	buff = input()
	(s2, p2, r2) = (0, 0, 0)
	for i in buff:
		if i == 'R':
			r2 += 1
		elif i == 'P':
			p2 += 1
		elif i == 'S':
			s2 += 1
	wins = min(p1, r2) + min(s1, p2) + min(r1, s2)
	if nc % 2 == 1:
		nc += 1
	if wins >= nc // 2:
		won = True
	if won:
		print('YES')
		answ = []
		for i in buff:
			if i == 'R':
				if p1 > 0:
					p1 -= 1
					answ.append('P')
				else:
					answ.append(' ')
			elif i == 'P':
				if s1 > 0:
					s1 -= 1
					answ.append('S')
				else:
					answ.append(' ')
			elif r1 > 0:
				r1 -= 1
				answ.append('R')
			else:
				answ.append(' ')
		for i in range(answ.__len__()):
			if answ[i] == ' ':
				if r1 > 0:
					r1 -= 1
					answ[i] = 'R'
				elif s1 > 0:
					s1 -= 1
					answ[i] = 'S'
				else:
					p1 -= 1
					answ[i] = 'P'
		for i in answ:
			print(i, end='')
		print('')
	else:
		print('NO')


from math import gcd
t = int(input())
for i in range(t):
	n = int(input())
	(r, p, s) = map(int, input().split())
	bob = input()
	ans = [0] * n
	cnt = 0
	for j in range(n):
		if bob[j] == 'R' and p > 0:
			p -= 1
			ans[j] = 'P'
			cnt += 1
		if bob[j] == 'P' and s > 0:
			s -= 1
			cnt += 1
			ans[j] = 'S'
		if bob[j] == 'S' and r > 0:
			r -= 1
			ans[j] = 'R'
			cnt += 1
	if cnt * 2 >= n:
		print('YES')
		for j in range(n):
			if ans[j] == 0:
				if p > 0:
					p -= 1
					ans[j] = 'P'
				elif r > 0:
					r -= 1
					ans[j] = 'R'
				else:
					s -= 1
					ans[j] = 'S'
		print(''.join(ans))
	else:
		print('NO')


import sys

def I():
	return sys.stdin.readline().rstrip()
for _ in range(int(I())):
	n = int(I())
	c = list(map(int, I().split()))
	m = ['R', 'P', 'S']
	d = ['S', 'R', 'P']
	bob = I()
	alice = []
	ans = 0
	for h in bob:
		i = d.index(h)
		al = None
		if c[i] > 0:
			c[i] -= 1
			al = m[i]
			ans += 1
		alice.append(al)
	for i in range(n):
		if alice[i] == None:
			for j in range(3):
				if c[j] > 0:
					c[j] -= 1
					alice[i] = m[j]
					break
	if ans >= (n + 1) // 2:
		print('YES')
		print(''.join(alice))
	else:
		print('NO')


import sys
input = sys.stdin.readline
N = int(input())
for _ in range(N):
	k = int(input())
	a = list(map(int, input().split()))
	b = list(input())[:-1]
	res = []
	c = 0
	for i in range(k):
		if b[i] == 'R' and a[1] > 0:
			c += 1
			a[1] -= 1
			res.append('P')
		elif b[i] == 'S' and a[0] > 0:
			c += 1
			a[0] -= 1
			res.append('R')
		elif b[i] == 'P' and a[2] > 0:
			c += 1
			a[2] -= 1
			res.append('S')
		else:
			res.append('?')
	if c >= -(-k // 2):
		print('YES')
		rres = ''
		for i in range(k):
			if res[i] == '?':
				if a[0] > 0:
					rres += 'R'
					a[0] -= 1
				elif a[1] > 0:
					rres += 'P'
					a[1] -= 1
				elif a[2] > 0:
					rres += 'S'
					a[2] -= 1
			else:
				rres += res[i]
		print(rres)
	else:
		print('NO')


import sys
test = int(input())
for case in range(test):
	n = int(input())
	(r, p, s) = map(int, input().split())
	bob = list(input())
	(x, w) = (0, n // 2 + n % 2)
	win = [False] * n
	for i in range(len(bob)):
		if bob[i] == 'R' and p > 0:
			win[i] = True
			x += 1
			p -= 1
		elif bob[i] == 'P' and s > 0:
			win[i] = True
			x += 1
			s -= 1
		elif bob[i] == 'S' and r > 0:
			win[i] = True
			x += 1
			r -= 1
	if x >= w:
		print('YES')
		for i in range(len(bob)):
			if win[i] == True:
				if bob[i] == 'R':
					print('P', end='')
				if bob[i] == 'P':
					print('S', end='')
				if bob[i] == 'S':
					print('R', end='')
			elif r > 0:
				r -= 1
				print('R', end='')
			elif p > 0:
				p -= 1
				print('P', end='')
			elif s > 0:
				s -= 1
				print('S', end='')
		print('')
	else:
		print('NO')


t = int(input())
import math
for _ in range(t):
	n = int(input())
	(p, s, r) = map(int, input().split())
	st = input()
	P = st.count('P')
	S = st.count('S')
	R = st.count('R')
	ans = min(r, P) + min(s, R) + min(p, S)
	import math
	if int(ans) < math.ceil(n / 2):
		print('NO')
	else:
		print('YES')
		l = [0] * n
		for i in range(len(st)):
			if st[i] == 'P' and r > 0:
				l[i] = 'S'
				r -= 1
			elif st[i] == 'S' and p > 0:
				l[i] = 'R'
				p -= 1
			elif st[i] == 'R' and s > 0:
				l[i] = 'P'
				s -= 1
		for i in range(len(st)):
			if l[i] == 0 and r > 0:
				l[i] = 'S'
				r -= 1
			elif l[i] == 0 and p > 0:
				l[i] = 'R'
				p -= 1
			elif l[i] == 0 and s > 0:
				l[i] = 'P'
				s -= 1
		print(''.join(map(str, l)))


from math import ceil
t = int(input())
slow = {'S': 'R', 'R': 'P', 'P': 'S'}
for _ in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	slow2 = {'S': a, 'R': b, 'P': c}
	res = 0
	ans = [''] * n
	for i in range(n):
		if slow2[s[i]] > 0:
			res += 1
			ans[i] = slow[s[i]]
			slow2[s[i]] -= 1
	if res >= ceil(n / 2):
		for i in range(n):
			if ans[i] == '':
				if slow2[s[i]] > 0:
					ans[i] = slow[s[i]]
					slow2[s[i]] -= 1
				elif slow2[slow[s[i]]] > 0:
					ans[i] = slow[slow[s[i]]]
					slow2[slow[s[i]]] -= 1
				else:
					slow2[slow[slow[s[i]]]] -= 1
					ans[i] = slow[slow[slow[s[i]]]]
		print('YES')
		print(''.join(ans))
	else:
		print('NO')


for t in range(int(input())):
	n = int(input())
	(a, b, c) = map(int, input().split())
	si = input()
	r = 0
	p = 0
	s = 0
	for i in range(n):
		if si[i] == 'R':
			r += 1
		elif si[i] == 'P':
			p += 1
		else:
			s += 1
	win = min(a, s) + min(b, r) + min(c, p)
	x = n // 2
	x += n % 2
	if win < x:
		print('NO')
	else:
		print('YES')
		f = ''
		fi = []
		for i in range(n):
			if si[i] == 'P':
				if c > 0:
					f += 'S'
					c -= 1
				else:
					fi.append(i)
			elif si[i] == 'R':
				if b > 0:
					f += 'P'
					b -= 1
				else:
					fi.append(i)
			elif a > 0:
				f += 'R'
				a -= 1
			else:
				fi.append(i)
		cur = 0
		cu2 = 0
		st = ''
		if len(fi) == 0:
			print(f)
			continue
		for i in range(a):
			st += 'R'
		for i in range(b):
			st += 'P'
		for i in range(c):
			st += 'S'
		d = ''
		for i in range(n):
			if cur >= len(fi):
				d += f[cu2]
				cu2 += 1
			elif i == fi[cur]:
				d += st[cur]
				cur += 1
			else:
				d += f[cu2]
				cu2 += 1
		print(d)


def main():
	t = int(input())
	while t:
		t -= 1
		n = int(input())
		(Ra, Pa, Sa) = [int(i) for i in input().split(' ')]
		s = input()
		Rb = s.count('R')
		Pb = s.count('P')
		Sb = s.count('S')
		T = min(Pa, Rb) + min(Sa, Pb) + min(Ra, Sb)
		if T >= int((n + 1) / 2.0):
			(sn, i) = ([''] * len(s), 0)
			while i < len(s):
				if s[i] == 'R' and Pa:
					sn[i] = 'P'
					Pa -= 1
				elif s[i] == 'P' and Sa:
					sn[i] = 'S'
					Sa -= 1
				elif s[i] == 'S' and Ra:
					sn[i] = 'R'
					Ra -= 1
				else:
					sn[i] = ''
				i += 1
			i = 0
			while i < len(s):
				if sn[i] == '':
					if Pa:
						sn[i] = 'P'
						Pa -= 1
					elif Sa:
						sn[i] = 'S'
						Sa -= 1
					elif Ra:
						sn[i] = 'R'
						Ra -= 1
				i += 1
			print('YES')
			print(''.join(sn))
		else:
			print('NO')
main()


import math
t = int(input())
for _ in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	si = input()
	r = 0
	p = 0
	s = 0
	for x in si:
		if x == 'R':
			r += 1
		elif x == 'P':
			p += 1
		else:
			s += 1
	wp = min(r, b)
	ws = min(p, c)
	wr = min(s, a)
	wins = wp + ws + wr
	r = a - wr
	p = b - wp
	s = c - ws
	if wins >= math.ceil(n / 2):
		print('YES')
		for x in si:
			if x == 'S':
				if wr > 0:
					print('R', end='')
					wr -= 1
				elif p > 0:
					print('P', end='')
					p -= 1
				elif s > 0:
					print('S', end='')
					s -= 1
			elif x == 'R':
				if wp > 0:
					print('P', end='')
					wp -= 1
				elif r > 0:
					print('R', end='')
					r -= 1
				elif s > 0:
					print('S', end='')
					s -= 1
			elif ws > 0:
				print('S', end='')
				ws -= 1
			elif p > 0:
				print('P', end='')
				p -= 1
			elif r > 0:
				print('R', end='')
				r -= 1
		print()
	else:
		print('NO')


t = int(input())
while t > 0:
	n = int(input())
	(ar, ap, asc) = input().split()
	ar = int(ar)
	ap = int(ap)
	asc = int(asc)
	bob = input()
	s = [0] * n
	br = 0
	bp = 0
	bs = 0
	check = 0
	for i in range(0, n):
		if bob[i] == 'R':
			br += 1
		elif bob[i] == 'P':
			bp += 1
		elif bob[i] == 'S':
			bs += 1
	if n % 2 == 0:
		check = n // 2
	else:
		check = n // 2 + 1
	if min(ar, bs) + min(ap, br) + min(asc, bp) >= check:
		print('YES')
		for i in range(0, n):
			if bob[i] == 'R' and ap > 0:
				ap -= 1
				s[i] = 'P'
			elif bob[i] == 'P' and asc > 0:
				asc -= 1
				s[i] = 'S'
			elif bob[i] == 'S' and ar > 0:
				ar -= 1
				s[i] = 'R'
		for i in range(0, n):
			if s[i] == 0 and ap > 0:
				s[i] = 'P'
				ap -= 1
			elif s[i] == 0 and asc > 0:
				s[i] = 'S'
				asc -= 1
			elif s[i] == 0 and ar > 0:
				s[i] = 'R'
				ar -= 1
		print(*s, sep='')
	else:
		print('NO')
	t = t - 1


t = int(input())
for i in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	sa = input()
	s = list(sa)
	a2 = sa.count('R')
	b2 = sa.count('P')
	c2 = sa.count('S')
	liste = []
	flag = 0
	sume = 0
	sume = min(b, a2) + min(c, b2) + min(a, c2)
	if 2 * sume >= n:
		flag = 1
	if flag == 1:
		for j in range(n):
			if s[j] == 'S' and a > 0:
				liste.append('R')
				a -= 1
			elif s[j] == 'R' and b > 0:
				liste.append('P')
				b -= 1
			elif s[j] == 'P' and c > 0:
				liste.append('S')
				c -= 1
			else:
				liste.append('_')
		print('YES')
		for j in range(n):
			if liste[j] != '_':
				continue
			if a > 0:
				liste[j] = 'R'
				a -= 1
			elif b > 0:
				liste[j] = 'P'
				b -= 1
			else:
				liste[j] = 'S'
				c -= 1
		print(''.join(liste))
	else:
		print('NO')


import math

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
for _ in range(int(input())):
	n = int(input())
	a = {}
	c = 0
	(r, p, s) = map(int, input().split())
	a['R'] = 0
	a['P'] = 0
	a['S'] = 0
	st = input()
	for i in st:
		a[i] += 1
	x = min(a['R'], p)
	c += x
	x = min(a['S'], r)
	c += x
	x = min(a['P'], s)
	c += x
	if math.ceil((r + p + s) / 2) <= c:
		print('YES')
		tc = ['0'] * n
		ur = []
		up = []
		us = []
		for i in range(n):
			if st[i] == 'R':
				ur.append(i)
			elif st[i] == 'P':
				up.append(i)
			else:
				us.append(i)
		for i in ur:
			if p > 0:
				tc[i] = 'P'
				p -= 1
			else:
				break
		for i in us:
			if r > 0:
				tc[i] = 'R'
				r -= 1
			else:
				break
		for i in up:
			if s > 0:
				tc[i] = 'S'
				s -= 1
			else:
				break
		for i in range(n):
			if tc[i] == '0':
				if r > 0:
					tc[i] = 'R'
					r -= 1
				elif p > 0:
					tc[i] = 'P'
					p -= 1
				elif s > 0:
					tc[i] = 'S'
					s -= 1
		print(''.join(tc))
	else:
		print('NO')


import math
t = int(input())
for i in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	x = 0
	y = 0
	z = 0
	for i in range(n):
		if s[i] == 'R':
			x += 1
	for i in range(n):
		if s[i] == 'P':
			y += 1
	for i in range(n):
		if s[i] == 'S':
			z += 1
	d = [0] * n
	s = list(s)
	if min(x, b) + min(y, c) + min(z, a) < math.ceil(n / 2):
		print('NO')
	else:
		print('YES')
		for i in range(n):
			if s[i] == 'S' and a:
				d[i] = 'R'
				a -= 1
			elif s[i] == 'R' and b:
				d[i] = 'P'
				b -= 1
			elif s[i] == 'P' and c:
				d[i] = 'S'
				c -= 1
		for i in range(n):
			if d[i] != 0:
				continue
			if a:
				d[i] = 'R'
				a -= 1
			elif b:
				d[i] = 'P'
				b -= 1
			else:
				d[i] = 'S'
				c -= 1
		for i in range(n):
			print(d[i], end='')
	print()


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = I()
	rr = []
	for _ in range(t):
		n = I()
		a = LI()
		s = S()
		r = [None] * n
		t = 0
		for (i, c) in enumerate(s):
			if c == 'R' and a[1] > 0:
				r[i] = 'P'
				a[1] -= 1
			elif c == 'P' and a[2] > 0:
				r[i] = 'S'
				a[2] -= 1
			elif c == 'S' and a[0] > 0:
				r[i] = 'R'
				a[0] -= 1
			else:
				t += 1
		if t > n // 2:
			rr.append('NO')
		else:
			u = 'RPS'
			for i in range(n):
				if r[i] is None:
					for j in range(3):
						if a[j] > 0:
							r[i] = u[j]
							a[j] -= 1
							break
			rr.append('YES')
			rr.append(JA(r, ''))
	return JA(rr, '\n')
print(main())


import copy

def getchar(s):
	global a, b, c
	if s == 'R':
		return 'P'
	elif s == 'P':
		return 'S'
	elif s == 'S':
		return 'R'
	if a > 0:
		a -= 1
		return 'R'
	if b > 0:
		b -= 1
		return 'P'
	if c > 0:
		c -= 1
		return 'S'
t = int(input())
for j in range(t):
	n = int(input())
	cc = 0
	(a, b, c) = map(int, input().split())
	s = list(input())
	ds = copy.copy(s)
	for i in range(n):
		if s[i] == 'R':
			if b > 0:
				b -= 1
				cc += 1
				s[i] = ''
		elif s[i] == 'P':
			if c > 0:
				c -= 1
				cc += 1
				s[i] = ''
		elif a > 0:
			a -= 1
			cc += 1
			s[i] = ''
	if (n + 1) // 2 <= cc:
		print('YES')
		for i in range(n):
			if s[i] == '':
				print(getchar(ds[i]), end='')
			else:
				print(getchar(''), end='')
		print()
	else:
		print('NO')


import math
t = int(input())
while t:
	t += -1
	n = int(input())
	(a, b, c) = [int(x) for x in input().split()]
	s = input()
	R = 0
	P = 0
	S = 0
	for i in s:
		if i == 'R':
			P -= -1
		elif i == 'P':
			S -= -1
		else:
			R -= -1
	eR = max(0, a - R)
	eP = max(0, b - P)
	eS = max(0, c - S)
	R = min(a, R)
	P = min(b, P)
	S = min(c, S)
	if R + P + S < math.ceil(n / 2):
		print('NO')
	else:
		print('YES')
		cc = 0
		for i in s:
			cc -= -1
			if i == 'R':
				if b > 0:
					print('P', end='')
					b += -1
				elif eR > 0:
					print('R', end='')
					eR += -1
				elif eS > 0:
					print('S', end='')
					eS += -1
			elif i == 'P':
				if c > 0:
					print('S', end='')
					c += -1
				elif eR > 0:
					print('R', end='')
					eR += -1
				elif eP > 0:
					print('P', end='')
					eP += -1
			elif a > 0:
				print('R', end='')
				a += -1
			elif eS > 0:
				print('S', end='')
				eS += -1
			elif eP > 0:
				print('P', end='')
				eP += -1
			if cc == len(s):
				print()


import math
t = int(input())
for _ in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	r = 0
	l = [0] * n
	for i in range(n):
		if s[i] == 'R':
			b -= 1
			if b >= 0:
				r += 1
				l[i] = 'P'
		elif s[i] == 'P':
			c -= 1
			if c >= 0:
				r += 1
				l[i] = 'S'
		else:
			a -= 1
			if a >= 0:
				r += 1
				l[i] = 'R'
	if r >= math.ceil(n / 2):
		print('YES')
		for i in range(n):
			if l[i] != 0:
				print(l[i], end='')
			elif a > 0:
				print('R', end='')
				a -= 1
			elif b > 0:
				print('P', end='')
				b -= 1
			elif c > 0:
				print('S', end='')
				c -= 1
		print()
	else:
		print('NO')


import math
t = int(input())
for i in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	(ales, bles, cles) = (0, 0, 0)
	seq = list(input())
	for j in range(n):
		if seq[j] == 'S':
			ales += 1
		elif seq[j] == 'R':
			bles += 1
		elif seq[j] == 'P':
			cles += 1
	ans = min(a, ales) + min(b, bles) + min(c, cles)
	if ans >= (n + 1) // 2:
		print('YES')
		(ales, bles, cles) = (min(a, ales), min(b, bles), min(c, cles))
		for j in range(n):
			if seq[j] == 'S' and ales > 0:
				ales -= 1
				a -= 1
				seq[j] = 'R'
			elif seq[j] == 'R' and bles > 0:
				bles -= 1
				b -= 1
				seq[j] = 'P'
			elif seq[j] == 'P' and cles > 0:
				cles -= 1
				c -= 1
				seq[j] = 'S'
			else:
				seq[j] = '_'
		for j in range(n):
			if seq[j] == '_':
				if a > 0:
					seq[j] = 'R'
					a -= 1
				elif b > 0:
					seq[j] = 'P'
					b -= 1
				elif c > 0:
					seq[j] = 'S'
					c -= 1
		print('%s' % ''.join((str(v) for v in seq)))
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	answer = [-1] * n
	win = 0
	for i in range(n):
		if s[i] == 'R' and b > 0:
			answer[i] = 2
			b -= 1
			win += 1
		elif s[i] == 'P' and c > 0:
			answer[i] = 3
			c -= 1
			win += 1
		elif s[i] == 'S' and a > 0:
			answer[i] = 1
			a -= 1
			win += 1
	if win >= (n + 1) // 2:
		print('YES')
		i = 0
		while a > 0:
			if answer[i] == -1:
				answer[i] = 1
				a -= 1
			i += 1
		while b > 0:
			if answer[i] == -1:
				answer[i] = 2
				b -= 1
			i += 1
		while c > 0:
			if answer[i] == -1:
				answer[i] = 3
				c -= 1
			i += 1
		ans = ''
		for i in range(n):
			if answer[i] == 1:
				ans += 'R'
			elif answer[i] == 2:
				ans += 'P'
			elif answer[i] == 3:
				ans += 'S'
		print(ans)
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	(r, p, s) = list(map(int, input().split()))
	c = input()
	(r1, p1, s1) = (r - c.count('S'), p - c.count('R'), s - c.count('P'))
	won = 0
	sol = ''
	for x in c:
		if x == 'S':
			if r > 0:
				sol += 'R'
				won += 1
				r -= 1
			elif p1 == max(p1, s1):
				sol += 'P'
				p -= 1
				p1 -= 1
			else:
				sol += 'S'
				s -= 1
				s1 -= 1
		elif x == 'R':
			if p > 0:
				sol += 'P'
				won += 1
				p -= 1
			elif r1 == max(r1, s1):
				sol += 'R'
				r -= 1
				r1 -= 1
			else:
				sol += 'S'
				s -= 1
				s1 -= 1
		elif s > 0:
			sol += 'S'
			won += 1
			s -= 1
		elif r1 == max(r1, p1):
			sol += 'R'
			r -= 1
			r1 -= 1
		else:
			sol += 'P'
			p -= 1
			p1 -= 1
	if won >= n // 2 + (1 if n & 1 else 0):
		print('YES')
		print(sol)
	else:
		print('NO')


import math
I = input
for _ in range(int(I())):
	n = int(I())
	(a, b, c) = map(int, I().split())
	s = list(I())
	d = {'P': [], 'R': [], 'S': []}
	for i in range(n):
		d[s[i]].append(i)
	ans = 0
	ans += min(len(d['R']), b)
	ans += min(len(d['P']), c)
	ans += min(len(d['S']), a)
	if math.ceil(n / 2) > ans:
		print('no')
	else:
		print('yes')
		l = []
		for i in d['R']:
			if b > 0:
				s[i] = 'P'
				b -= 1
			else:
				l.append(i)
		for i in d['P']:
			if c > 0:
				s[i] = 'S'
				c -= 1
			else:
				l.append(i)
		for i in d['S']:
			if a > 0:
				s[i] = 'R'
				a -= 1
			else:
				l.append(i)
		for i in l:
			if a > 0:
				s[i] = 'R'
				a -= 1
			elif b > 0:
				s[i] = 'P'
				b -= 1
			else:
				s[i] = 'S'
				c -= 1
		print(''.join(s))


from sys import stdin
from collections import Counter
from math import ceil
winmap = {'R': 'P', 'P': 'S', 'S': 'R'}
for _ in range(int(stdin.readline())):
	n = ceil(int(stdin.readline()) / 2)
	(r, p, s) = map(int, stdin.readline().split())
	bob = stdin.readline().strip()
	bobby = Counter(bob)
	rwin = min(r, bobby['S'])
	pwin = min(p, bobby['R'])
	swin = min(s, bobby['P'])
	if rwin + pwin + swin < n:
		print('NO')
	else:
		print('YES')
		antibob = []
		''.join([winmap[b] for b in bob])
		rex = r - bobby['S']
		pex = p - bobby['R']
		sex = s - bobby['P']
		for b in bob:
			want = winmap[b]
			if want == 'R':
				if rex >= 0:
					antibob.append(want)
				elif pex > 0:
					antibob.append('P')
					rex += 1
					pex -= 1
				else:
					antibob.append('S')
					rex += 1
					sex -= 1
			elif want == 'P':
				if pex >= 0:
					antibob.append(want)
				elif rex > 0:
					antibob.append('R')
					pex += 1
					rex -= 1
				else:
					antibob.append('S')
					pex += 1
					sex -= 1
			elif want == 'S':
				if sex >= 0:
					antibob.append(want)
				elif rex > 0:
					antibob.append('R')
					sex += 1
					rex -= 1
				else:
					antibob.append('P')
					sex += 1
					pex -= 1
		print(''.join(antibob))


import math
cases = int(input())
for case in range(cases):
	n = int(input())
	(a_rock, a_paper, a_scissors) = map(int, input().split())
	(rocks, papers, scissors) = (0, 0, 0)
	b_plays = input()
	for c in b_plays:
		if c == 'R' and a_paper:
			a_paper -= 1
			papers += 1
		if c == 'P' and a_scissors:
			a_scissors -= 1
			scissors += 1
		if c == 'S' and a_rock:
			a_rock -= 1
			rocks += 1
	if sum([rocks, papers, scissors]) * 2 >= n:
		print('YES')
		for c in b_plays:
			if c == 'R' and papers:
				papers -= 1
				print('P', end='')
			elif c == 'P' and scissors:
				scissors -= 1
				print('S', end='')
			elif c == 'S' and rocks:
				rocks -= 1
				print('R', end='')
			elif a_rock:
				a_rock -= 1
				print('R', end='')
			elif a_paper:
				a_paper -= 1
				print('P', end='')
			elif a_scissors:
				a_scissors -= 1
				print('S', end='')
		print('')
	else:
		print('NO')


from math import ceil
t = int(input())
for i in range(t):
	n = int(input())
	(a, b, c) = list(map(int, input().split()))
	s = input()
	RN = 0
	SN = 0
	PN = 0
	for j in s:
		if j == 'R':
			RN += 1
		elif j == 'S':
			SN += 1
		else:
			PN += 1
	Win = max(0, min(b, RN)) + max(0, min(c, PN)) + max(0, min(a, SN))
	Afree = max(0, a - min(a, SN))
	Bfree = max(0, b - min(b, RN))
	Cfree = max(0, c - min(c, PN))
	if Win < ceil(n / 2):
		print('NO')
	else:
		ans = ''
		for k in range(n):
			if s[k] == 'R':
				if b > 0:
					b -= 1
					ans += 'P'
				elif Afree > 0:
					Afree -= 1
					ans += 'R'
				else:
					Cfree -= 1
					ans += 'S'
			elif s[k] == 'P':
				if c > 0:
					c -= 1
					ans += 'S'
				elif Afree > 0:
					Afree -= 1
					ans += 'R'
				else:
					Bfree -= 1
					ans += 'P'
			elif a > 0:
				a -= 1
				ans += 'R'
			elif Bfree > 0:
				Bfree -= 1
				ans += 'P'
			else:
				Cfree -= 1
				ans += 'S'
		print('YES')
		print(ans)


import math
for i in range(int(input())):
	n = int(input())
	(r, p, s) = map(int, input().split())
	res = []
	win = 0
	st = input()
	x = r
	y = p
	z = s
	for i in st:
		if i == 'R':
			if p > 0:
				win += 1
				p = p - 1
				res.append('P')
			else:
				res.append(-1)
		elif i == 'P':
			if s > 0:
				win += 1
				s = s - 1
				res.append('S')
			else:
				res.append(-1)
		elif r > 0:
			win += 1
			r = r - 1
			res.append('R')
		else:
			res.append(-1)
	j = 0
	while r != 0:
		if res[j] == -1:
			r = r - 1
			res[j] = 'R'
		j += 1
	j = 0
	while p != 0:
		if res[j] == -1:
			p = p - 1
			res[j] = 'P'
		j += 1
	j = 0
	while s != 0:
		if res[j] == -1:
			s = s - 1
			res[j] = 'S'
		j += 1
	if len(res) == n:
		if win >= math.ceil(n / 2):
			if res.count('R') == x and res.count('P') == y and (res.count('S') == z):
				print('yes')
				print(''.join(res))
			else:
				print('no')
		else:
			print('no')
	else:
		print('no')


t = int(input())
import math
for i in range(t):
	res = 0
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	ss = []
	for j in s:
		if j == 'R':
			if b > 0:
				b = b - 1
				ss.append('P')
				res = res + 1
			else:
				ss.append('0')
		elif j == 'P':
			if c > 0:
				c = c - 1
				ss.append('S')
				res = res + 1
			else:
				ss.append('0')
		elif j == 'S':
			if a > 0:
				a = a - 1
				ss.append('R')
				res = res + 1
			else:
				ss.append('0')
	if res >= math.ceil(n / 2):
		for k in range(len(ss)):
			if ss[k] == '0':
				if a > 0:
					ss[k] = 'R'
					a = a - 1
				elif b > 0:
					ss[k] = 'P'
					b = b - 1
				elif c > 0:
					ss[k] = 'S'
					c = c - 1
		print('YES')
		print(''.join(ss))
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	rps = list(map(int, input().split()))
	bob = input().strip()
	sol = []
	for b in bob:
		need = 'SRP'.index(b)
		sol.append('RPS'[need] if rps[need] else 'x')
		if rps[need]:
			rps[need] -= 1
	if sol.count('x') * 2 > len(bob):
		print('NO')
	else:
		print('YES')
		left = ['RPS'[n] for n in range(3) for _ in range(rps[n])]
		print(''.join((left.pop() if s == 'x' else s for s in sol)))


t = int(input())
for i in range(t):
	n = int(input())
	(a, b, c) = map(int, input().strip().split())
	s = input()
	minWin = n // 2 + n % 2
	plays = {}
	plays['R'] = 0
	plays['P'] = 0
	plays['S'] = 0
	for i in s:
		plays[i] += 1
	wins = 0
	wins += min(a, plays['S']) + min(b, plays['R']) + min(c, plays['P'])
	if wins < minWin:
		print('NO')
	else:
		print('YES')
		alice = ['' for i in range(n)]
		for i in range(n):
			if s[i] == 'R' and b > 0:
				alice[i] = 'P'
				b -= 1
			elif s[i] == 'P' and c > 0:
				alice[i] = 'S'
				c -= 1
			elif s[i] == 'S' and a > 0:
				alice[i] = 'R'
				a -= 1
		for i in range(n):
			if alice[i] == '':
				if a > 0:
					a -= 1
					alice[i] = 'R'
				elif b > 0:
					b -= 1
					alice[i] = 'P'
				elif c > 0:
					c -= 1
					alice[i] = 'S'
		answer = ''
		for i in alice:
			answer += i
		print(answer)


t = int(input())
for _ in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	tot = 0
	aa = s.count('S')
	bb = s.count('R')
	cc = s.count('P')
	tot = 0
	tot += min(a, aa)
	tot += min(b, bb)
	tot += min(c, cc)
	x = n // 2
	if n % 2 == 1:
		x += 1
	if tot >= x:
		print('YES')
		ss = [i for i in s]
		j = 0
		tt = ['' for i in range(n)]
		co = 0
		for i in ss:
			if not a:
				break
			if i == 'S':
				tt[j] = 'R'
				a -= 1
			j += 1
		j = 0
		for i in ss:
			if not b:
				break
			if i == 'R':
				tt[j] = 'P'
				b -= 1
			j += 1
		j = 0
		for i in ss:
			if not c:
				break
			if i == 'P':
				tt[j] = 'S'
				c -= 1
			j += 1
		for i in range(n):
			if tt[i] == '':
				if a:
					tt[i] = 'R'
					a -= 1
				elif b:
					tt[i] = 'P'
					b -= 1
				elif c:
					tt[i] = 'S'
					c -= 1
		print(''.join(tt))
	else:
		print('NO')


for _ in ' ' * int(input()):
	from math import ceil as f
	a = int(input())
	(b, c, d) = map(int, input().split())
	e = input()
	if max(0, e.count('R') - c) + max(0, e.count('S') - b) + max(0, e.count('P') - d) > a // 2:
		print('NO')
		continue
	print('YES')
	s = []
	for i in e:
		if i == 'R':
			if c:
				c -= 1
				s += 'P'
			else:
				s += 'o'
				continue
		if i == 'P':
			if d:
				s += 'S'
				d -= 1
			else:
				s += 'o'
				continue
		if i == 'S':
			if b:
				s += 'R'
				b -= 1
			else:
				s += 'o'
	for i in range(a):
		if s[i] == 'o':
			if b:
				s[i] = 'R'
				b -= 1
			elif c:
				s[i] = 'P'
				c -= 1
			elif d:
				s[i] = 'S'
				d -= 1
	print(*s, sep='')


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return map(int, input().split())

def array():
	return [int(i) for i in input().split()]
for _ in range(int(input())):
	n = int(input())
	(a, b, c) = value()
	s = input()
	C = Counter(s)
	W = {}
	W['S'] = [min(a, C['S']), 'R']
	W['R'] = [min(b, C['R']), 'P']
	W['P'] = [min(c, C['P']), 'S']
	tot = sum((i[0] for i in W.values()))
	if tot >= ceil(n / 2) and tot != 0:
		print('YES')
		faltu = {'R': a - W['S'][0], 'P': b - W['R'][0], 'S': c - W['P'][0]}
		for i in s:
			if W[i][0] != 0:
				print(W[i][1], end='')
				W[i][0] -= 1
			else:
				for j in faltu:
					if faltu[j] != 0:
						faltu[j] -= 1
						print(j, end='')
						break
		print()
	else:
		print('NO')


import math
a = int(input())
for i in range(a):
	n = int(input())
	(r, p, ss) = map(int, input().split())
	s = input()
	k = []
	count = 0
	for i in range(len(s)):
		if s[i] == 'R':
			if p > 0:
				k.append('P')
				p = p - 1
				count = count + 1
			else:
				k.append(0)
		elif s[i] == 'P':
			if ss > 0:
				k.append('S')
				ss = ss - 1
				count = count + 1
			else:
				k.append(0)
		elif r > 0:
			k.append('R')
			r = r - 1
			count = count + 1
		else:
			k.append(0)
	for i in range(len(k)):
		if k[i] == 0:
			if r > 0:
				k[i] = 'R'
				r = r - 1
			elif ss > 0:
				k[i] = 'S'
				ss = ss - 1
			else:
				k[i] = 'P'
				p = p - 1
	if count >= math.ceil(n / 2):
		print('YES')
		print(''.join(map(str, k)))
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	(r, p, sc) = (s.count('R'), s.count('P'), s.count('S'))
	(mr, mp, ms) = (min(r, b), min(p, c), min(sc, a))
	if 2 * (mr + mp + ms) >= n:
		print('YES')
		print(s.replace('R', 'p', mr).replace('P', 's', mp).replace('S', 'r', ms).replace('R', '*').replace('S', '*').replace('P', '*').replace('*', 'r', a - ms).replace('*', 'p', b - mr).replace('*', 's', c - mp).upper())
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	(c, a, b) = [int(x) for x in input().split()]
	st = input()
	(a1, b1, c1) = (st.count('R'), st.count('P'), st.count('S'))
	if min(a, a1) + min(b, b1) + min(c, c1) < n / 2:
		print('NO')
	else:
		print('YES')
		(ost_a, ost_b, ost_c) = (max(0, a - a1), max(0, b - b1), max(0, c - c1))
		(a, b, c) = (min(a, a1), min(b, b1), min(c, c1))
		for j in range(len(st)):
			if st[j] == 'R':
				if a > 0:
					a -= 1
					print('P', end='')
				elif ost_b > 0:
					ost_b -= 1
					print('S', end='')
				else:
					ost_c -= 1
					print('R', end='')
			elif st[j] == 'P':
				if b > 0:
					b -= 1
					print('S', end='')
				elif ost_a > 0:
					ost_a -= 1
					print('P', end='')
				else:
					ost_c -= 1
					print('R', end='')
			elif c > 0:
				c -= 1
				print('R', end='')
			elif ost_a > 0:
				ost_a -= 1
				print('P', end='')
			else:
				ost_b -= 1
				print('S', end='')
	print()


import math
t = int(input())
for q in range(0, t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	a1 = a
	b1 = b
	c1 = c
	s = input()
	count = 0
	ans1 = ['t'] * n
	for i in range(0, len(s)):
		if s[i] == 'R' and b != 0:
			b -= 1
			count += 1
			ans1[i] = 'P'
		elif s[i] == 'P' and c != 0:
			c -= 1
			count += 1
			ans1[i] = 'S'
		elif s[i] == 'S' and a != 0:
			a -= 1
			count += 1
			ans1[i] = 'R'
	m = math.ceil(n / 2)
	if m > count:
		print('NO')
	else:
		print('YES')
		for i in range(0, n):
			if ans1[i] == 't':
				if a != 0:
					ans1[i] = 'R'
					a -= 1
				elif b != 0:
					ans1[i] = 'P'
					b -= 1
				else:
					ans1[i] = 'S'
					c -= 1
		print(*ans1, sep='')


import math
for test in range(int(input())):
	n = int(input())
	(R, P, S) = map(int, input().strip().split(' '))
	bob = input()
	r = p = s = 0
	for i in range(len(bob)):
		if bob[i] == 'R':
			r += 1
		if bob[i] == 'S':
			s += 1
		if bob[i] == 'P':
			p += 1
	ans = 0
	result = [1] * len(bob)
	for i in range(len(bob)):
		if bob[i] == 'R':
			if P > 0:
				result[i] = 'P'
				ans += 1
				P -= 1
			else:
				break
	for i in range(len(bob)):
		if bob[i] == 'S':
			if R > 0:
				result[i] = 'R'
				ans += 1
				R -= 1
			else:
				break
	for i in range(len(bob)):
		if bob[i] == 'P':
			if S > 0:
				result[i] = 'S'
				ans += 1
				S -= 1
			else:
				break
	for i in range(len(bob)):
		if result[i] == 1:
			if P > 0:
				result[i] = 'P'
				P -= 1
				continue
			if R > 0:
				result[i] = 'R'
				R -= 1
				continue
			if S > 0:
				result[i] = 'S'
				S -= 1
				continue
	if ans >= math.ceil(n / 2):
		print('Yes')
		print(''.join(result))
	else:
		print('No')


n = int(input())
from collections import defaultdict

def main():
	n = int(input())
	(a, b, c) = map(int, input().split())
	Alice = {'R': a, 'P': b, 'S': c}
	t = input()
	Bob = defaultdict(int)
	for s in t:
		Bob[s] += 1
	a1 = Bob['S'] - Alice['R']
	a2 = Bob['R'] - Alice['P']
	a3 = Bob['P'] - Alice['S']
	wins = [min(Bob['S'], Alice['R']), min(Bob['R'], Alice['P']), min(Bob['P'], Alice['S'])]
	loses = [a - wins[0], b - wins[1], c - wins[2]]
	if sum(wins) < sum(loses):
		print('NO')
	else:
		print('YES')
		strAlice = ''
		for s in t:
			if s == 'S':
				if wins[0] > 0:
					strAlice += 'R'
					wins[0] -= 1
				elif loses[1] > 0:
					strAlice += 'P'
					loses[1] -= 1
					continue
				elif loses[2] > 0:
					strAlice += 'S'
					loses[2] -= 1
					continue
			elif s == 'R':
				if wins[1] > 0:
					strAlice += 'P'
					wins[1] -= 1
				elif loses[2] > 0:
					strAlice += 'S'
					loses[2] -= 1
					continue
				elif loses[0] > 0:
					strAlice += 'R'
					loses[0] -= 1
					continue
			elif s == 'P':
				if wins[2] > 0:
					strAlice += 'S'
					wins[2] -= 1
				elif loses[0] > 0:
					strAlice += 'R'
					loses[0] -= 1
					continue
				elif loses[1] > 0:
					strAlice += 'P'
					loses[1] -= 1
					continue
		print(strAlice)
for i in range(n):
	main()


from math import ceil
t = int(input())
for w in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	a1 = 0
	b1 = 0
	c1 = 0
	for i in range(n):
		if s[i] == 'R':
			a1 += 1
		elif s[i] == 'P':
			b1 += 1
		else:
			c1 += 1
	w = min(a, c1) + min(b, a1) + min(c, b1)
	if w < ceil(n / 2):
		print('NO')
	else:
		print('YES')
		ans = ['T'] * n
		for i in range(n):
			if s[i] == 'S':
				if a > 0:
					ans[i] = 'R'
					a -= 1
			elif s[i] == 'P':
				if c > 0:
					ans[i] = 'S'
					c -= 1
			elif b > 0:
				ans[i] = 'P'
				b -= 1
		for i in range(n):
			if ans[i] == 'T':
				if a > 0:
					ans[i] = 'R'
					a -= 1
				elif b > 0:
					ans[i] = 'P'
					b -= 1
				elif c > 0:
					ans[i] = 'S'
					c -= 1
		for i in range(n):
			print(ans[i], end='')
		print()


t = int(input())
from math import *
while t > 0:
	t -= 1
	n = int(input())
	(r, p, s) = map(int, input().split())
	si = input()
	st = [0 for i in range(len(si))]
	v = [0 for i in range(len(si))]
	c = 0
	for i in range(len(si)):
		if si[i] == 'R':
			if p > 0:
				p -= 1
				st[i] = 'P'
				c += 1
			else:
				v[i] = 1
		elif si[i] == 'P':
			if s > 0:
				s -= 1
				st[i] = 'S'
				c += 1
			else:
				v[i] = 1
		elif r > 0:
			r -= 1
			st[i] = 'R'
			c += 1
		else:
			v[i] = 1
	baki = r * 'R' + p * 'P' + s * 'S'
	j = 0
	for i in range(len(st)):
		if v[i] == 1:
			st[i] = baki[j]
			j += 1
	if c >= int(ceil(n / 2)):
		print('YES')
		print(''.join(st))
	else:
		print('NO')


import math
for i in range(int(input())):
	su = int(input())
	(a, b, c) = map(int, input().split())
	r = 0
	s = input()
	res = ''
	for j in s:
		if j == 'R':
			if b > 0:
				b -= 1
				res += 'P'
				r += 1
			else:
				res += ' '
		elif j == 'P':
			if c > 0:
				c -= 1
				res += 'S'
				r += 1
			else:
				res += ' '
		elif a > 0:
			a -= 1
			res += 'R'
			r += 1
		else:
			res += ' '
	res2 = ''
	for j in range(len(res)):
		if res[j] == ' ':
			if a > 0:
				res2 += 'R'
				a -= 1
			elif b > 0:
				res2 += 'P'
				b -= 1
			else:
				res2 += 'S'
				c -= 1
		else:
			res2 += res[j]
	if r >= math.ceil(su / 2):
		print('YES')
		print(res2)
	else:
		print('NO')


import sys
input = sys.stdin.readline
import math
t = int(input())
for i in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	rps = [i for i in input()]
	rock = rps.count('R')
	paper = rps.count('P')
	scissor = rps.count('S')
	prob = min(rock, b) + min(paper, c) + min(scissor, a)
	if prob < math.ceil(n / 2):
		print('NO')
	else:
		output = [0] * n
		for i in range(n):
			if rps[i] == 'R':
				if b > 0:
					output[i] = 'P'
					b -= 1
		for i in range(n):
			if rps[i] == 'P':
				if c > 0:
					output[i] = 'S'
					c -= 1
		for i in range(n):
			if rps[i] == 'S':
				if a > 0:
					output[i] = 'R'
					a -= 1
		for i in range(n):
			if output[i] == 0:
				if a > 0:
					output[i] = 'R'
					a -= 1
				elif c > 0:
					output[i] = 'S'
					c -= 1
				else:
					output[i] = 'P'
					b -= 1
		print('YES')
		print(''.join(output))


t = int(input())
for i in range(0, t):
	n = int(input())
	(r, p, s) = (0, 0, 0)
	l = list(map(int, input().split()))
	st = input()
	for j in st:
		if j == 'R':
			r += 1
		elif j == 'P':
			p += 1
		else:
			s += 1
	m = min(l[0], s) + min(l[1], r) + min(l[2], p)
	if m < (n + 1) // 2:
		print('NO')
	else:
		print('YES')
		(a, b, c) = (l[0] - s, l[1] - r, l[2] - p)
		l1 = ['R'] * max(0, a) + ['P'] * max(0, b) + ['S'] * max(0, c)
		for j in st:
			if j == 'R':
				if l[1] > 0:
					print('P', end='')
					l[1] -= 1
				else:
					print(l1.pop(), end='')
			if j == 'P':
				if l[2] > 0:
					print('S', end='')
					l[2] -= 1
				else:
					print(l1.pop(), end='')
			if j == 'S':
				if l[0] > 0:
					print('R', end='')
					l[0] -= 1
				else:
					print(l1.pop(), end='')
		print()


for _ in range(int(input())):
	n = int(input())
	(a, b, c) = map(int, input().split())
	l = list(input())
	seq = list()
	win = n // 2 + n % 2
	ans = 0
	for j in l:
		if j == 'R':
			if b:
				ans += 1
				b -= 1
				seq.append('P')
			else:
				seq.append(' ')
		elif j == 'P':
			if c:
				ans += 1
				c -= 1
				seq.append('S')
			else:
				seq.append(' ')
		elif j == 'S':
			if a > 0:
				ans += 1
				a -= 1
				seq.append('R')
			else:
				seq.append(' ')
	if ans < win:
		print('NO')
	else:
		print('YES')
		for i in range(n):
			if seq[i] == ' ':
				if a:
					seq[i] = 'R'
					a -= 1
				elif b:
					seq[i] = 'P'
					b -= 1
				else:
					seq[i] = 'S'
					c -= 1
		print(''.join(seq))


for _ in range(int(input())):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	w = 0
	r = []
	for d in s:
		if d == 'R':
			if b > 0:
				r.append('P')
				b -= 1
				w += 1
			else:
				r.append('*')
		if d == 'P':
			if c > 0:
				r.append('S')
				c -= 1
				w += 1
			else:
				r.append('*')
		if d == 'S':
			if a > 0:
				r.append('R')
				a -= 1
				w += 1
			else:
				r.append('*')
	if w >= (n + 1) // 2:
		print('YES')
		for (i, _) in enumerate(r):
			if r[i] == '*':
				if a > 0:
					r[i] = 'R'
					a -= 1
				elif b > 0:
					r[i] = 'P'
					b -= 1
				else:
					r[i] = 'S'
					c -= 1
		print(''.join(r))
	else:
		print('NO')


import math
t = int(input())
for _ in range(t):
	n = int(input())
	(a, b, c) = list(map(int, input().split()))
	s = input()
	d = {}
	d['R'] = a
	d['P'] = b
	d['S'] = c
	q = {}
	q['R'] = 'P'
	q['P'] = 'S'
	q['S'] = 'R'
	ans = 0
	f = ''
	for i in range(n):
		if d[q[s[i]]] > 0:
			ans = ans + 1
			f = f + q[s[i]]
			d[q[s[i]]] = d[q[s[i]]] - 1
		else:
			f = f + '$'
	f = list(f)
	for i in range(len(f)):
		if f[i] == '$':
			if d['R'] > 0:
				f[i] = 'R'
				d['R'] = d['R'] - 1
			elif d['P'] > 0:
				f[i] = 'P'
				d['P'] = d['P'] - 1
			elif d['S'] > 0:
				f[i] = 'S'
				d['S'] = d['S'] - 1
	if ans >= int(math.ceil(n / 2)):
		print('YES')
		ans = ''
		for i in range(len(f)):
			ans = ans + f[i]
		print(ans)
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	cnt = 0
	res = [''] * n
	for j in range(n):
		if s[j] == 'R':
			if b != 0:
				b -= 1
				cnt += 1
				res[j] = 'P'
		elif s[j] == 'S':
			if a != 0:
				a -= 1
				cnt += 1
				res[j] = 'R'
		elif c != 0:
			c -= 1
			cnt += 1
			res[j] = 'S'
	if cnt >= -(-n // 2):
		print('YES')
		for k in range(n):
			if res[k] == '':
				if a:
					a -= 1
					res[k] = 'R'
				elif b:
					b -= 1
					res[k] = 'P'
				else:
					c -= 1
					res[k] = 'S'
		for i in res:
			print(i, end='')
		print()
	else:
		print('NO')


import math
t = int(input())
while t:
	t -= 1
	n = int(input())
	(a, b, c) = list(map(int, input().split()))
	s = input()
	ans = 0
	s1 = [None] * n
	i = 0
	for char in s:
		if char == 'R':
			if b > 0:
				b -= 1
				ans += 1
				s1[i] = 'P'
		elif char == 'P':
			if c > 0:
				c -= 1
				ans += 1
				s1[i] = 'S'
		elif a > 0:
			a -= 1
			ans += 1
			s1[i] = 'R'
		i += 1
	if int(math.ceil(n / 2)) <= ans:
		print('YES')
		for i in range(n):
			if s1[i] == None:
				if a > 0:
					s1[i] = 'R'
					a -= 1
				elif b > 0:
					s1[i] = 'P'
					b -= 1
				elif c > 0:
					s1[i] = 'S'
					c -= 1
		print(''.join(s1))
	else:
		print('NO')


import sys

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
for _ in range(INT()):
	N = INT()
	(rcnt, pcnt, scnt) = MAP()
	S = input()
	win = 0
	ans = [''] * N
	for (i, s) in enumerate(S):
		if s == 'R':
			if pcnt > 0:
				pcnt -= 1
				win += 1
				ans[i] = 'P'
		elif s == 'P':
			if scnt > 0:
				scnt -= 1
				win += 1
				ans[i] = 'S'
		elif rcnt > 0:
			rcnt -= 1
			win += 1
			ans[i] = 'R'
	for i in range(N):
		if ans[i] == '':
			if rcnt > 0:
				ans[i] = 'R'
				rcnt -= 1
			elif pcnt > 0:
				ans[i] = 'P'
				pcnt -= 1
			else:
				ans[i] = 'S'
				scnt -= 1
	if win >= ceil(N, 2):
		YES()
		print(''.join(ans))
	else:
		NO()


import math
for _ in range(int(input())):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = list(input())
	aa = s.count('R')
	bb = s.count('P')
	cc = s.count('S')
	pp = min(aa, b) + min(bb, c) + min(cc, a)
	if pp < math.ceil(n / 2):
		print('NO')
	else:
		print('YES')
		fb = [0] * len(s)
		for i in range(len(s)):
			if s[i] == 'R' and b > 0:
				fb[i] = 'P'
				b -= 1
			if s[i] == 'P' and c > 0:
				fb[i] = 'S'
				c -= 1
			if s[i] == 'S' and a > 0:
				fb[i] = 'R'
				a -= 1
		for i in range(len(fb)):
			if fb[i] == 0:
				if a > 0:
					fb[i] = 'R'
					a -= 1
				elif b > 0:
					fb[i] = 'P'
					b -= 1
				else:
					fb[i] = 'S'
					c -= 1
		qq = ''
		for i in range(len(fb)):
			qq += fb[i]
		print(qq)


from math import ceil
t = int(input())
for i in range(t):
	n = int(input())
	(ar, ap, aS) = map(int, input().split())
	s = input()
	(br, bp, bs) = (0, 0, 0)
	for x in s:
		if x == 'R':
			br += 1
		elif x == 'P':
			bp += 1
		else:
			bs += 1
	su = min(ar, bs) + min(ap, br) + min(aS, bp)
	if su >= ceil(n / 2):
		print('YES')
		s = list(s)
		ans = [0] * n
		for i in range(n):
			if s[i] == 'R' and ap != 0:
				ans[i] = 'P'
				ap -= 1
			if s[i] == 'P' and aS != 0:
				ans[i] = 'S'
				aS -= 1
			if s[i] == 'S' and ar != 0:
				ans[i] = 'R'
				ar -= 1
		for i in range(n):
			if ans[i] == 0:
				if ap != 0:
					ans[i] = 'P'
					ap -= 1
				elif ar != 0:
					ans[i] = 'R'
					ar -= 1
				elif aS != 0:
					ans[i] = 'S'
					aS -= 1
		print(*ans, sep='')
	else:
		print('NO')


from collections import Counter
for i in range(int(input())):
	n = int(input())
	arr = [int(i) for i in input().split()]
	dic = {}
	dic['R'] = arr[0]
	dic['P'] = arr[1]
	dic['S'] = arr[2]
	s = input()
	cnt = Counter([i for i in s])
	ans = ['-'] * n
	win = 0
	draw = 0
	for i in range(len(s)):
		if s[i] == 'R':
			if dic['P'] > 0:
				dic['P'] -= 1
				ans[i] = 'P'
				win += 1
		if s[i] == 'P':
			if dic['S'] > 0:
				dic['S'] -= 1
				ans[i] = 'S'
				win += 1
		if s[i] == 'S':
			if dic['R'] > 0:
				dic['R'] -= 1
				ans[i] = 'R'
				win += 1
	for i in range(len(s)):
		if s[i] == '-':
			if s[i] == 'R':
				if dic['R'] > 0:
					dic['R'] -= 1
					ans[i] = 'R'
					draw += 1
			if s[i] == 'P':
				if dic['P'] > 0:
					dic['P'] -= 1
					ans[i] = 'P'
					draw += 1
			if s[i] == 'S':
				if dic['S'] > 0:
					dic['S'] -= 1
					ans[i] = 'S'
					draw += 1
	for i in range(len(s)):
		if ans[i] == '-':
			if dic['R'] > 0:
				ans[i] = 'R'
				dic['R'] -= 1
			elif dic['S'] > 0:
				ans[i] = 'S'
				dic['S'] -= 1
			elif dic['P'] > 0:
				ans[i] = 'P'
				dic['P'] -= 1
	if win >= (n + 1) // 2:
		print('YES')
		print(''.join(ans))
	else:
		print('NO')


t = int(input())
for test in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split(' '))
	s = input()
	res = []
	for i in range(n):
		res.append('0')
	a1 = 0
	b1 = 0
	c1 = 0
	for i in range(n):
		if s[i] == 'R':
			a1 += 1
		elif s[i] == 'P':
			b1 += 1
		elif s[i] == 'S':
			c1 += 1
	res1 = min(a, c1) + min(b, a1) + min(c, b1)
	if res1 < (n + 1) // 2:
		print('NO')
	else:
		print('YES')
		for i in range(n):
			if s[i] == 'R':
				if b > 0:
					res[i] = 'P'
					b -= 1
			elif s[i] == 'P':
				if c > 0:
					res[i] = 'S'
					c -= 1
			elif a > 0:
				res[i] = 'R'
				a -= 1
		for i in range(n):
			if res[i] == '0':
				if a > 0:
					res[i] = 'R'
					a -= 1
				elif b > 0:
					res[i] = 'P'
					b -= 1
				else:
					res[i] = 'S'
					c -= 1
		print(''.join(res))


import math as mt
import sys, string, bisect
input = sys.stdin.readline
import random
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
t = I()
for i in range(t):
	n = I()
	(a, b, c) = M()
	s = list(input().strip())
	v = [0] * n
	score = 0
	for i in range(n):
		if s[i] == 'S' and a > 0 and (v[i] == 0):
			a -= 1
			v[i] = 1
			s[i] = 'R'
			score += 1
		elif s[i] == 'R' and b > 0 and (v[i] == 0):
			b -= 1
			v[i] = 1
			s[i] = 'P'
			score += 1
		elif s[i] == 'P' and c > 0 and (v[i] == 0):
			c -= 1
			v[i] = 1
			s[i] = 'S'
			score += 1
	for i in range(n):
		if a + b + c > 0 and v[i] == 0:
			if a > 0:
				a -= 1
				s[i] = 'R'
				v[i] = 1
			elif b > 0:
				b -= 1
				s[i] = 'P'
				v[i] = 1
			else:
				c -= 1
				s[i] = 'S'
				v[i] = 1
		if a + b + c == 0:
			break
	if score >= mt.ceil(n / 2):
		print('YES')
		for i in s:
			print(i, end='')
		print()
	else:
		print('NO')


import math
for _ in range(int(input())):
	n = int(input())
	rps = [int(x) for x in input().split()]
	r = rps[0]
	p = rps[1]
	s = rps[2]
	seq = list(input())
	ans = 0
	ans_s = []
	bob_r = bob_p = bob_s = 0
	for i in range(len(seq)):
		c = seq[i]
		if c == 'R':
			bob_r += 1
		elif c == 'P':
			bob_p += 1
		elif c == 'S':
			bob_s += 1
		ans_s.append('X')
	for i in range(len(seq)):
		c = seq[i]
		mx_bob = max(bob_r, bob_p, bob_s)
		if c == 'R' and p > 0:
			bob_r -= 1
			p -= 1
			ans += 1
			ans_s[i] = 'P'
		elif c == 'P' and s > 0:
			bob_p -= 1
			s -= 1
			ans += 1
			ans_s[i] = 'S'
		elif c == 'S' and r > 0:
			bob_s -= 1
			r -= 1
			ans += 1
			ans_s[i] = 'R'
	for i in range(len(seq)):
		if ans_s[i] == 'X':
			if r > 0:
				ans_s[i] = 'R'
				r -= 1
			elif p > 0:
				ans_s[i] = 'P'
				p -= 1
			elif s > 0:
				ans_s[i] = 'S'
				s -= 1
	if ans >= math.ceil(n / 2):
		print('YES\n' + ''.join(ans_s))
	else:
		print('NO')


T = int(input())
for i in range(T):
	n = int(input())
	if n % 2 == 0:
		ceil = n // 2
	else:
		ceil = n // 2 + 1
	RPS = input().split()
	R = int(RPS[0])
	P = int(RPS[1])
	S = int(RPS[2])
	my_RPS = []
	for i in range(n):
		my_RPS.append(0)
	oppo = str(input())
	for i in range(n):
		if oppo[i] == 'R':
			if P:
				my_RPS[i] = 'P'
				P -= 1
		elif oppo[i] == 'P':
			if S:
				my_RPS[i] = 'S'
				S -= 1
		elif R:
			my_RPS[i] = 'R'
			R -= 1
	if n - (R + P + S) >= ceil:
		my_rps = ''
		for i in range(n):
			if my_RPS[i] == 0:
				if P:
					my_rps += 'P'
					P -= 1
				elif S:
					my_rps += 'S'
					S -= 1
				elif R:
					my_rps += 'R'
					R -= 1
			else:
				my_rps += my_RPS[i]
		print('YES' + '\n' + my_rps)
	else:
		print('NO')


import math
t = int(input())
for i in range(t):
	n = int(input())
	(a, b, c) = list(map(int, input().strip().split()))
	string = input()
	countr = 0
	countp = 0
	counts = 0
	for i in range(n):
		if string[i] == 'R':
			countr += 1
		elif string[i] == 'P':
			countp += 1
		elif string[i] == 'S':
			counts += 1
	first1 = min(a, counts)
	first2 = min(b, countr)
	first3 = min(c, countp)
	ceilnumber = math.ceil(n / 2)
	final = []
	for i in range(n):
		final.append(0)
	if first1 + first2 + first3 >= ceilnumber:
		print('YES')
		for i in range(n):
			if string[i] == 'R' and b > 0:
				final[i] = 'P'
				b = b - 1
			elif string[i] == 'P' and c > 0:
				final[i] = 'S'
				c = c - 1
			elif string[i] == 'S' and a > 0:
				final[i] = 'R'
				a = a - 1
		for i in range(n):
			if final[i] == 0:
				if a > 0:
					final[i] = 'R'
					a = a - 1
				elif b > 0:
					final[i] = 'P'
					b = b - 1
				elif c > 0:
					final[i] = 'S'
					c = c - 1
		for i in range(n):
			print(final[i], end='')
		print('')
	else:
		print('NO')


from sys import stdin
import math
A = int(stdin.readline())
for t in range(0, A):
	record2 = ''
	B = int(stdin.readline())
	C = list(map(int, stdin.readline().split()))
	D = stdin.readline()
	D = D[0:len(D) - 1]
	Rcount = 0
	Pcount = 0
	Scount = 0
	for z in D:
		if z == 'R':
			Rcount += 1
		if z == 'P':
			Pcount += 1
		if z == 'S':
			Scount += 1
	G = min(C[0], Scount) + min(C[1], Rcount) + min(C[2], Pcount)
	S1 = C[0] - Scount
	S2 = C[1] - Rcount
	S3 = C[2] - Pcount
	E = C.copy()
	if G >= math.ceil(B / 2):
		print('YES')
		for p in D:
			if p == 'R':
				if E[1] > 0:
					record2 += 'P'
					E[1] -= 1
				elif S1 > 0:
					S1 -= 1
					E[0] -= 1
					record2 += 'R'
				else:
					S3 -= 1
					E[2] -= 1
					record2 += 'S'
			elif p == 'P':
				if E[2] > 0:
					record2 += 'S'
					E[2] -= 1
				elif S2 > 0:
					S2 -= 1
					E[1] -= 1
					record2 += 'P'
				else:
					S1 -= 1
					E[0] -= 1
					record2 += 'R'
			elif E[0] > 0:
				record2 += 'R'
				E[0] -= 1
			elif S3 > 0:
				S3 -= 1
				E[2] -= 1
				record2 += 'S'
			else:
				record2 += 'P'
				S2 -= 1
				E[1] -= 1
		print(record2)
	else:
		print('NO')


import math
import sys
from collections import defaultdict
rt = lambda : map(int, input().split())
ri = lambda : int(input())
rl = lambda : list(map(int, input().split()))

def solve(n, a):
	pass

def main():
	T = ri()
	for t in range(T):
		n = ri()
		(r, p, s) = rt()
		bob = str(input())
		r_bob = bob.count('R')
		p_bob = bob.count('P')
		s_bob = bob.count('S')
		target = (n + 1) // 2
		wins = min(p, r_bob) + min(s, p_bob) + min(r, s_bob)
		if target > wins:
			print('NO')
		else:
			print('YES')
			res = ['_'] * n
			use_p = min(p, r_bob)
			use_s = min(s, p_bob)
			use_r = min(r, s_bob)
			for (i, c) in enumerate(bob):
				if c == 'R' and use_p > 0:
					res[i] = 'P'
					use_p -= 1
					p -= 1
				if c == 'P' and use_s > 0:
					res[i] = 'S'
					use_s -= 1
					s -= 1
				if c == 'S' and use_r > 0:
					res[i] = 'R'
					use_r -= 1
					r -= 1
			for i in range(len(res)):
				if res[i] == '_':
					if r > 0:
						res[i] = 'R'
						r -= 1
					elif s > 0:
						res[i] = 'S'
						s -= 1
					else:
						res[i] = 'P'
						p -= 1
			print(''.join(res))
main()


from math import ceil

def inp(type):
	return type(input())

def minput(type):
	return map(type, input().split())

def linput(type):
	return list(minput(type))

def check(map, elem):
	if not map.__contains__(elem):
		map[elem] = set()
d1 = {'R': 'P', 'P': 'S', 'S': 'R'}
d2 = {'R': 0, 'P': 1, 'S': 2}
d3 = 'RPS'
for _ in range(inp(int)):
	n = inp(int)
	a = linput(int)
	s = input()
	b = [a[0], a[1], a[2]]
	cc = 0
	for c in s:
		if c == '\n':
			break
		b[d2[d1[c]]] -= 1
		if b[d2[d1[c]]] >= 0:
			cc += 1
	if cc >= ceil(n / 2):
		print('YES')
		for c in s:
			if c == '\n':
				break
			if a[d2[d1[c]]] > 0:
				a[d2[d1[c]]] -= 1
				print(d1[c], end='')
			else:
				for i in range(3):
					if b[i] > 0:
						b[i] -= 1
						print(d3[i], end='')
						break
		print()
	else:
		print('NO')


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input().strip()
	(aw, bw, cw) = (min(a, s.count('S')), min(b, s.count('R')), min(c, s.count('P')))
	if aw + bw + cw < (n + 1) // 2:
		print('NO')
		continue
	print('YES')
	(ar, br, cr) = (max(a - aw, 0), max(b - bw, 0), max(c - cw, 0))
	ls = ['R'] * ar + ['P'] * br + ['S'] * cr
	ans = ''
	for ch in s:
		if ch == 'R' and bw > 0:
			ans += 'P'
			bw -= 1
			continue
		if ch == 'P' and cw > 0:
			ans += 'S'
			cw -= 1
			continue
		if ch == 'S' and aw > 0:
			ans += 'R'
			aw -= 1
			continue
		ans += ls.pop()
	print(ans)


for _ in range(int(input())):
	n = int(input())
	(rock, paper, cis) = map(int, input().split())
	s = input()
	item = [0, 0, 0]
	for it in s:
		if it == 'R':
			item[0] += 1
		elif it == 'P':
			item[1] += 1
		else:
			item[2] += 1
	win = 0
	ro = min(rock, item[2])
	win += ro
	pa = min(paper, item[0])
	win += pa
	ci = min(cis, item[1])
	win += ci
	ans = []
	if win >= (n + 1) // 2:
		print('YES')
		for c in s:
			if c == 'R':
				if pa > 0:
					pa -= 1
					paper -= 1
					ans.append('P')
				elif rock > ro:
					ans.append('R')
					rock -= 1
				else:
					ans.append('S')
					cis -= 1
			elif c == 'P':
				if ci > 0:
					ci -= 1
					cis -= 1
					ans.append('S')
				elif rock > ro:
					ans.append('R')
					rock -= 1
				else:
					ans.append('P')
					paper -= 1
			elif ro > 0:
				ro -= 1
				rock -= 1
				ans.append('R')
			elif cis > ci:
				ans.append('S')
				cis -= 1
			else:
				ans.append('P')
				paper -= 1
		print(''.join(ans))
	else:
		print('NO')


def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
t = int(input())
for i in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	ans = []
	count = 0
	for i in range(n):
		if s[i] == 'R':
			if b != 0:
				b -= 1
				ans.append('P')
				count += 1
			else:
				ans.append('')
		elif s[i] == 'P':
			if c != 0:
				c -= 1
				ans.append('S')
				count += 1
			else:
				ans.append('')
		elif a != 0:
			a -= 1
			ans.append('R')
			count += 1
		else:
			ans.append('')
	if count < n // 2 + (n % 2 == 1):
		print('NO')
	else:
		print('YES')
		for i in range(n):
			if ans[i] == '':
				if a != 0:
					a -= 1
					ans[i] = 'R'
				elif b != 0:
					b -= 1
					ans[i] = 'P'
				else:
					c -= 1
					ans[i] = 'S'
		print(''.join(ans))


t = int(input())
for _ in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	ro = s.count('R')
	pa = s.count('P')
	si = s.count('S')
	k1 = min(a, si) + min(b, ro) + min(c, pa)
	if 2 * k1 >= n:
		print('YES')
		q = [0] * n
		for i in range(0, n):
			if s[i] == 'R' and b != 0:
				q[i] = 'P'
				b -= 1
			elif s[i] == 'P' and c != 0:
				q[i] = 'S'
				c -= 1
			elif s[i] == 'S' and a != 0:
				q[i] = 'R'
				a -= 1
		for i in range(0, n):
			if q[i] == 0 and b != 0:
				q[i] = 'P'
				b -= 1
			elif q[i] == 0 and c != 0:
				q[i] = 'S'
				c -= 1
			elif q[i] == 0 and a != 0:
				q[i] = 'R'
				a -= 1
		print(''.join(map(str, q)))
	else:
		print('NO')


from sys import stdin, stdout
from collections import Counter

def ai():
	return list(map(int, stdin.readline().split()))

def ei():
	return map(int, stdin.readline().split())

def ip():
	return int(stdin.readline().strip())

def op(ans):
	return stdout.write(str(ans) + '\n')
from math import ceil
t = ip()
for i in range(t):
	n = ip()
	win = ceil(n / 2)
	(a, b, c) = ei()
	s = input()
	final = 0
	ans = [None for i in range(n)]
	for i in range(n):
		if s[i] == 'S' and a > 0:
			a -= 1
			ans[i] = 'R'
			final += 1
		if s[i] == 'P' and c > 0:
			c -= 1
			ans[i] = 'S'
			final += 1
		if s[i] == 'R' and b > 0:
			b -= 1
			ans[i] = 'P'
			final += 1
	if final < win:
		print('NO')
	else:
		for i in range(len(s)):
			if ans[i] != None:
				continue
			if a > 0:
				ans[i] = 'R'
				a -= 1
			elif b > 0:
				ans[i] = 'P'
				b -= 1
			elif c > 0:
				ans[i] = 'S'
				c -= 1
		print('YES')
		print(''.join(ans))


import math
for _ in range(int(input())):
	n = int(input())
	(r, p, s) = map(int, input().split())
	a = input()
	times = 0
	ans = ''
	for i in a:
		if i == 'R':
			if p > 0:
				p -= 1
				ans += 'P'
				times += 1
			else:
				ans += '*'
		elif i == 'P':
			if s > 0:
				s -= 1
				ans += 'S'
				times += 1
			else:
				ans += '*'
		elif i == 'S':
			if r > 0:
				r -= 1
				ans += 'R'
				times += 1
			else:
				ans += '*'
	if times >= math.ceil(n / 2):
		final = ''
		for i in ans:
			if i == '*':
				if r > 0:
					final += 'R'
					r -= 1
				elif p > 0:
					final += 'P'
					p -= 1
				elif s > 0:
					final += 'S'
					s -= 1
			else:
				final += i
		print('YES')
		print(final)
	else:
		print('NO')


for i in range(int(input())):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	res = [''] * n
	w = 0
	for j in range(n):
		if s[j] == 'R' and b:
			b -= 1
			res[j] = 'P'
			w += 1
		elif s[j] == 'P' and c:
			c -= 1
			res[j] = 'S'
			w += 1
		elif s[j] == 'S' and a:
			a -= 1
			res[j] = 'R'
			w += 1
	for j in range(n):
		if res[j] == '':
			if a:
				res[j] = 'R'
				a -= 1
			elif b:
				res[j] = 'P'
				b -= 1
			elif c:
				res[j] = 'S'
				c -= 1
	if w >= (n + 1) // 2:
		print('YES')
		print(''.join(res))
	else:
		print('NO')


from sys import stdin, stdout
from collections import Counter
from itertools import permutations
import bisect
import math
I = lambda : map(int, stdin.readline().split())
I1 = lambda : stdin.readline()
for _ in range(int(I1())):
	n = int(I1())
	(r, p, s) = I()
	S = I1().strip()
	(r1, p1, s1) = (S.count('R'), S.count('P'), S.count('S'))
	w = min(r, s1) + min(p, r1) + min(s, p1)
	if w >= (n + 1) // 2:
		print('YES')
		l = [0] * n
		for i in range(n):
			if S[i] == 'S' and r > 0:
				l[i] = 'R'
				r -= 1
			elif S[i] == 'R' and p > 0:
				l[i] = 'P'
				p -= 1
			elif S[i] == 'P' and s > 0:
				l[i] = 'S'
				s -= 1
		for i in range(n):
			if l[i] == 0:
				if r > 0:
					l[i] = 'R'
					r -= 1
				elif p > 0:
					l[i] = 'P'
					p -= 1
				else:
					l[i] = 'S'
					s -= 1
		print(''.join(l))
	else:
		print('NO')


import sys, math
input = lambda : sys.stdin.readline().rstrip()
for _ in range(int(input())):
	n = int(input())
	(a, b, c) = map(int, input().split())
	(a1, b1, c1) = (a, b, c)
	s = input()
	ans = 'NO'
	count = 0
	for i in s:
		if math.ceil(n / 2) > count:
			if i == 'P':
				if c != 0:
					c -= 1
					count += 1
			elif i == 'R':
				if b != 0:
					b -= 1
					count += 1
			elif i == 'S':
				if a != 0:
					a -= 1
					count += 1
		else:
			break
	if math.ceil(n / 2) <= count:
		ans = 'YES'
		print(ans)
		(da, db, dc) = (a1 - a, b1 - b, c1 - c)
		(oa, ob, oc) = (a1 - da, b1 - db, c1 - dc)
		for i in s:
			if i == 'P':
				if dc != 0:
					print('S', end='')
					dc -= 1
				elif oa != 0:
					print('R', end='')
					oa -= 1
				elif ob != 0:
					print('P', end='')
					ob -= 1
				elif oc != 0:
					print('S', end='')
					oc -= 1
			if i == 'S':
				if da != 0:
					print('R', end='')
					da -= 1
				elif oa != 0:
					print('R', end='')
					oa -= 1
				elif ob != 0:
					print('P', end='')
					ob -= 1
				elif oc != 0:
					print('S', end='')
					oc -= 1
			if i == 'R':
				if db != 0:
					print('P', end='')
					db -= 1
				elif oa != 0:
					print('R', end='')
					oa -= 1
				elif ob != 0:
					print('P', end='')
					ob -= 1
				elif oc != 0:
					print('S', end='')
					oc -= 1
		print()
	else:
		print(ans)


f = lambda i: (i + 1) % 3
for TT in range(1, int(input()) + 1):
	n = int(input())
	l = [*map(int, input().split())]
	s = ['RPS'.index(e) for e in input()]
	valid = True
	res = [-1] * n
	cnt = 0
	for (i, e) in enumerate(s):
		j = f(e)
		if l[j] > 0:
			l[j] -= 1
			res[i] = j
			cnt += 1
	j = 0
	for i in range(n):
		if res[i] != -1:
			continue
		while j < 3 and l[j] == 0:
			j += 1
		res[i] = j
		l[j] -= 1
	valid &= cnt >= (n + 1) // 2
	if valid:
		print('YES')
		print(''.join(('RPS'[e] for e in res)))
	else:
		print('NO')


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
import datetime, math, functools
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	longans = ''
	tc = 0
	for _ in range(int(input())):
		tc += 1
		n = int(input())
		(ra, pa, sa) = [int(x) for x in input().split()]
		(aaaa, bbbb, cccc) = (ra, pa, sa)
		s = input()
		ans = ''
		c = 0
		f = 0
		for i in range(n):
			if s[i] == 'R':
				if pa > 0:
					ans += 'P'
					pa -= 1
					c += 1
				else:
					ans += '#'
					f += 1
			if s[i] == 'P':
				if sa > 0:
					ans += 'S'
					sa -= 1
					c += 1
				else:
					ans += '#'
					f += 1
			if s[i] == 'S':
				if ra > 0:
					ans += 'R'
					ra -= 1
					c += 1
				else:
					ans += '#'
					f += 1
		if c >= (n + 1) // 2:
			ns = 'R' * ra + 'P' * pa + 'S' * sa
			ans1 = ''
			longans += 'YES\n'
			k = 0
			for i in range(n):
				if ans[i] == '#':
					ans1 += ns[k]
					k += 1
				else:
					ans1 += ans[i]
			longans += ans1 + '\n'
		else:
			longans += 'NO\n'
	print(longans)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from math import ceil
for _ in range(int(input())):
	n = int(input())
	(r, p, s) = map(int, input().split())
	g = input()
	t = min(r, g.count('S')) + min(p, g.count('R')) + min(s, g.count('P'))
	if t < ceil(n / 2):
		print('NO')
	else:
		print('YES')
		r1 = 0
		p1 = 0
		s1 = 0
		l = ['f'] * n
		for i in range(n):
			if g[i] == 'R' and p:
				l[i] = 'P'
				p -= 1
			elif g[i] == 'S' and r:
				l[i] = 'R'
				r -= 1
			elif g[i] == 'P' and s:
				l[i] = 'S'
				s -= 1
		for i in range(n):
			if l[i] == 'f':
				if p > 0:
					l[i] = 'P'
					p -= 1
				elif r > 0:
					l[i] = 'R'
					r -= 1
				elif s > 0:
					l[i] = 'S'
					s -= 1
		print(*l, sep='')


t = int(input())
for i in range(t):
	n = int(input())
	(r, p, s) = list(map(int, input().split()))
	st = input()
	rr = st.count('R')
	pp = st.count('P')
	ss = st.count('S')
	w = -(-n // 2)
	if min(r, ss) + min(s, pp) + min(p, rr) >= w:
		print('YES')
		ANS = ['n'] * n
		for j in range(n):
			if r > 0 and st[j] == 'S':
				ANS[j] = 'R'
				r -= 1
			elif p > 0 and st[j] == 'R':
				ANS[j] = 'P'
				p -= 1
			elif s > 0 and st[j] == 'P':
				ANS[j] = 'S'
				s -= 1
		for j in range(n):
			if ANS[j] == 'n':
				if r > 0:
					ANS[j] = 'R'
					r -= 1
				elif p > 0:
					ANS[j] = 'P'
					p -= 1
				elif s > 0:
					ANS[j] = 'S'
					s -= 1
		print(''.join(ANS))
	else:
		print('NO')


def fastio():
	import sys
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from collections import defaultdict as dd
from math import gcd
(t,) = I()
while t:
	t -= 1
	(n,) = I()
	(a, b, c) = I()
	s = input()
	alice = 0
	ans = [0] * n
	for i in range(n):
		if s[i] == 'R' and b:
			b -= 1
			ans[i] = 'P'
			alice += 1
		elif s[i] == 'P' and c:
			c -= 1
			ans[i] = 'S'
			alice += 1
		elif s[i] == 'S' and a:
			a -= 1
			ans[i] = 'R'
			alice += 1
	for i in range(n):
		if ans[i]:
			continue
		if a:
			a -= 1
			ans[i] = 'R'
		elif b:
			b -= 1
			ans[i] = 'P'
		else:
			c -= 1
			ans[i] = 'S'
	if alice >= n // 2 + n % 2:
		print('YES')
		print(''.join(ans))
	else:
		print('NO')


def ans(n):
	if n % 2 == 0:
		return int(n / 2)
	elif int(n // 2) % 2 == 0:
		return int(n // 2) + 1
	else:
		return int(n // 2) + 1
t = int(input())
for i in range(t):
	n = int(input())
	abc = list(map(int, input().split()))
	op = input()
	r = 0
	p = 0
	s = 0
	for j in range(n):
		if op[j] == 'R':
			r += 1
		elif op[j] == 'P':
			p += 1
		else:
			s += 1
	ll = list()
	for j in range(n):
		ll.append('Q')
	wins = 0
	wins = min(abc[1], r) + min(abc[2], p) + min(abc[0], s)
	if wins >= ans(n):
		print('YES')
		for j in range(n):
			if op[j] == 'R':
				if abc[1] > 0:
					ll[j] = 'P'
					abc[1] -= 1
			if op[j] == 'P':
				if abc[2] > 0:
					ll[j] = 'S'
					abc[2] -= 1
			if op[j] == 'S':
				if abc[0] > 0:
					ll[j] = 'R'
					abc[0] -= 1
		for j in range(n):
			if ll[j] == 'Q':
				if abc[0] > 0:
					ll[j] = 'R'
					abc[0] -= 1
				elif abc[1] > 0:
					ll[j] = 'P'
					abc[1] -= 1
				elif abc[2] > 0:
					ll[j] = 'S'
					abc[2] -= 1
		for j in range(n):
			print(ll[j], end='')
		print()
	else:
		print('NO')


from math import *
from collections import *
t = int(input())
for y in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	ct = 0
	l = ['0' for i in range(n)]
	for i in range(n):
		if s[i] == 'R' and b != 0:
			ct += 1
			l[i] = 'P'
			b -= 1
		elif s[i] == 'P' and c != 0:
			ct += 1
			l[i] = 'S'
			c -= 1
		elif s[i] == 'S' and a != 0:
			ct += 1
			l[i] = 'R'
			a -= 1
	for i in range(n):
		if l[i] == '0' and a != 0:
			l[i] = 'R'
			a -= 1
		elif l[i] == '0' and b != 0:
			l[i] = 'P'
			b -= 1
		elif l[i] == '0':
			l[i] = 'S'
			c -= 1
	if ct >= n / 2:
		print('YES')
		print(''.join(l))
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	count = 0
	ans = ['' for i in range(n)]
	for i in range(n):
		if s[i] == 'P' and c != 0:
			ans[i] = 'S'
			c -= 1
			count += 1
		if s[i] == 'S' and a != 0:
			a -= 1
			ans[i] = 'R'
			count += 1
		if s[i] == 'R' and b != 0:
			b -= 1
			count += 1
			ans[i] = 'P'
	for i in range(n):
		if ans[i] == '' and a != 0:
			ans[i] = 'R'
			a -= 1
		elif ans[i] == '' and b != 0:
			ans[i] = 'P'
			b -= 1
		elif ans[i] == '' and c != 0:
			ans[i] = 'S'
			c -= 1
	if count >= (n + 1) // 2:
		print('YES')
		print(*ans, sep='')
	else:
		print('NO')


def try_to_win(n, a, b, c, s):
	ans = ''
	idxs = []
	for i in range(n):
		if s[i] == 'S' and a:
			ans += 'R'
			a -= 1
		elif s[i] == 'R' and b:
			ans += 'P'
			b -= 1
		elif s[i] == 'P' and c:
			ans += 'S'
			c -= 1
		else:
			ans += ' '
			idxs.append(i)
	ans = list(ans)
	res = n - a - b - c
	if n % 2 == 0:
		half = n / 2
	else:
		half = n // 2 + 1
	if res < half:
		return 'NO'
	else:
		for i in idxs:
			if a:
				ans[i] = 'R'
				a -= 1
			elif b:
				ans[i] = 'P'
				b -= 1
			elif c:
				ans[i] = 'S'
				c -= 1
	return ['YES', ''.join(ans)]
t = int(input())
for i in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	answer = try_to_win(n, a, b, c, s)
	if type(answer) != str:
		print(answer[0])
		print(answer[1])
	else:
		print(answer)


t = int(input())
ans = []
for u in range(t):
	n = int(input())
	s = input().split()
	a = int(s[0])
	b = int(s[1])
	c = int(s[2])
	seqB = input()
	r = p = s = 0
	for e in seqB:
		if e == 'R':
			r += 1
		elif e == 'P':
			p += 1
		else:
			s += 1
	key = min([a, s]) + min([b, r]) + min([c, p])
	if key < (n + 1) // 2:
		ans.append('NO')
	else:
		ans.append('YES')
		mid = []
		for k in range(n):
			if seqB[k] == 'R':
				if b > 0:
					b -= 1
					mid.append('P')
				else:
					mid.append(0)
			if seqB[k] == 'P':
				if c > 0:
					c -= 1
					mid.append('S')
				else:
					mid.append(0)
			if seqB[k] == 'S':
				if a > 0:
					a -= 1
					mid.append('R')
				else:
					mid.append(0)
		for j in range(n):
			if mid[j] == 0:
				if a > 0:
					mid[j] = 'R'
					a -= 1
				elif b > 0:
					mid[j] = 'P'
					b -= 1
				else:
					mid[j] = 'S'
					c -= 1
		seqA = ''
		for x in mid:
			seqA += x
		ans.append(seqA)
for y in range(len(ans)):
	print(ans[y])


import sys
import math
import itertools
import collections

def getdict(n):
	d = {}
	if type(n) is list or type(n) is str:
		for i in n:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
	else:
		for i in range(n):
			t = ii()
			if t in d:
				d[t] += 1
			else:
				d[t] = 1
	return d

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def cdiv(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def wr(arr):
	return ''.join(map(str, arr))

def revn(n):
	return int(str(n)[::-1])

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base=3):
	newnumber = ''
	while number > 0:
		newnumber = str(number % base) + newnumber
		number //= base
	return newnumber
t = ii()
k = ['R', 'P', 'S']
for _ in range(t):
	n = ii()
	(a, b, c) = mi()
	s = input()
	bob = collections.Counter(s)
	w = [min(a, bob['S']), min(b, bob['R']), min(c, bob['P'])]
	if sum(w) >= math.ceil(n / 2):
		print('YES')
		ans = ['.'] * n
		d = [[] for i in range(3)]
		for i in range(n):
			if s[i] == 'R':
				d[1].append(i)
			elif s[i] == 'P':
				d[2].append(i)
			else:
				d[0].append(i)
		for i in range(3):
			for j in range(w[i]):
				ans[d[i][j]] = k[i]
		t = 'R' * (a - w[0]) + 'P' * (b - w[1]) + 'S' * (c - w[2])
		if len(t) > 0:
			j = 0
			for i in range(n):
				if ans[i] == '.':
					ans[i] = t[j]
					j += 1
			print(wr(ans))
		else:
			print(wr(ans))
	else:
		print('NO')


import math
t = int(input())
for i in range(t):
	n = int(input())
	(a, b, c) = list(map(int, input().split()))
	req = {'R': 0, 'P': 0, 'S': 0}
	move = {'R': 'P', 'P': 'S', 'S': 'R'}
	d = {}
	use = {}
	d['R'] = a
	d['P'] = b
	d['S'] = c
	win = 0
	s = input()
	for c in s:
		req[move[c]] += 1
	for i in 'RPS':
		use[i] = min(d[i], req[i])
		win += use[i]
	if win >= math.ceil(n / 2):
		print('YES')
		res = ''
		for c in s:
			if d[move[c]] > 0:
				use[move[c]] -= 1
				d[move[c]] -= 1
				res += move[c]
			else:
				for i in 'RPS':
					if d[i] - use[i] > 0:
						d[i] -= 1
						res += i
						break
		print(res)
	else:
		print('NO')


import fractions
import math
import sys
sys.setrecursionlimit(10 ** 8)
input = sys.stdin.readline
t = int(input())
for i in range(t):
	n = int(input())
	(ra, pa, sa) = [int(item) for item in input().split()]
	hand = input().rstrip()
	ans = []
	rb = hand.count('R')
	sb = hand.count('S')
	pb = hand.count('P')
	if min(ra, sb) + min(sa, pb) + min(pa, rb) >= math.ceil(n / 2):
		print('YES')
	else:
		print('NO')
		continue
	rr = max(ra - sb, 0)
	rs = max(sa - pb, 0)
	rp = max(pa - rb, 0)
	rest = 'R' * rr + 'S' * rs + 'P' * rp
	itr = 0
	for ch in hand:
		if ch == 'R' and pa > 0:
			ans.append('P')
			pa -= 1
		elif ch == 'P' and sa > 0:
			ans.append('S')
			sa -= 1
		elif ch == 'S' and ra > 0:
			ans.append('R')
			ra -= 1
		else:
			ans.append(rest[itr])
			itr += 1
	print(''.join([item for item in ans]))


import math
t = int(input())
for _ in range(t):
	n = int(input())
	win = [' '] * n
	(ar, ap, _as) = [int(_) for _ in input().split()]
	R = ['R'] * ar
	P = ['P'] * ap
	S = ['S'] * _as
	bob = input()
	c = 0
	for (index, elem) in enumerate(bob):
		if elem == 'R':
			if P:
				win[index] = P.pop()
				c = c + 1
		elif elem == 'P':
			if S:
				win[index] = S.pop()
				c = c + 1
		elif elem == 'S':
			if R:
				win[index] = R.pop()
				c = c + 1
	if c >= math.ceil(n / 2):
		print('YES')
		for (index, elem) in enumerate(win):
			if elem == ' ':
				if P:
					win[index] = P.pop()
				elif S:
					win[index] = S.pop()
				elif R:
					win[index] = R.pop()
		print(''.join(win))
	else:
		print('NO')


import math
cases = int(input())
for case in range(cases):
	n = int(input())
	t = [''] * n
	(a, b, c) = map(int, input().split())
	bob_hands = input()
	for i in range(n):
		if bob_hands[i] == 'R' and b:
			b -= 1
			t[i] = 'P'
		elif bob_hands[i] == 'P' and c:
			c -= 1
			t[i] = 'S'
		elif bob_hands[i] == 'S' and a:
			a -= 1
			t[i] = 'R'
	if (n - (a + b + c)) * 2 >= n:
		print('YES')
		for i in range(n):
			if t[i] == '':
				if a:
					a -= 1
					t[i] = 'R'
				elif b:
					b -= 1
					t[i] = 'P'
				elif c:
					c -= 1
					t[i] = 'S'
		print(''.join(t))
	else:
		print('NO')


from collections import defaultdict as dc
from collections import deque as dq
from bisect import bisect_left, bisect_right, insort_left
import sys
import math
mod = 10 ** 9 + 7

def bs(a, x):
	i = bisect_left(a, x)
	if i != len(a):
		return i
	else:
		return len(a)

def inp():
	p = int(input())
	return p

def line():
	p = list(map(int, input().split()))
	return p

def bs(a, b):
	l = a
	r = b + 1
	x = b
	ans = 0
	while l < r:
		mid = (l + r) // 2
		if x | mid > ans:
			ans = x | mid
			l = mid + 1
		else:
			r = mid
	return ans

def digit(n):
	a = []
	while n > 0:
		a.append(n % 10)
		n = n // 10
	return a
for _ in range(int(inp())):
	n = int(inp())
	(ar, bp, cs) = line()
	s = str(input())
	p = list(s)
	c = 0
	for i in range(n):
		if s[i] == 'S':
			if ar > 0:
				p[i] = 'R'
				ar = ar - 1
				c += 1
			else:
				p[i] = 'z'
		elif s[i] == 'R':
			if bp > 0:
				p[i] = 'P'
				bp = bp - 1
				c += 1
			else:
				p[i] = 'z'
		elif s[i] == 'P':
			if cs > 0:
				p[i] = 'S'
				cs = cs - 1
				c += 1
			else:
				p[i] = 'z'
	l = math.ceil(n / 2)
	if c >= l:
		print('YES')
		for i in range(n):
			if p[i] == 'z':
				if ar > 0:
					p[i] = 'R'
					ar = ar - 1
				elif bp > 0:
					p[i] = 'P'
					bp = bp - 1
				elif cs > 0:
					p[i] = 'S'
					cs = cs - 1
		print(''.join(p))
	else:
		print('NO')


def rint():
	return int(input())

def rints():
	return list(map(int, input().split()))
t = rint()
for _ in range(t):
	n = rint()
	(a, b, c) = rints()
	s = input()
	al = [None] * n
	for (i, ch) in enumerate(s):
		if ch == 'R' and b > 0:
			b -= 1
			al[i] = 'P'
		elif ch == 'P' and c > 0:
			c -= 1
			al[i] = 'S'
		elif ch == 'S' and a > 0:
			a -= 1
			al[i] = 'R'
	w = sum((1 for p in al if p is not None))
	if w < (n + 1) // 2:
		print('NO')
		continue
	for i in range(n):
		if al[i] is not None:
			continue
		if a > 0:
			a -= 1
			al[i] = 'R'
		elif b > 0:
			b -= 1
			al[i] = 'P'
		else:
			c -= 1
			al[i] = 'S'
	print('YES')
	print(''.join(al))


import sys
from collections import Counter
from math import ceil
W = {'S': 'R', 'R': 'P', 'P': 'S'}

def atoi(line):
	line = line.rstrip().split()
	return list(map(int, line))

def won(A, B):
	W_ct = dict()
	W_ct['S'] = min(A['R'], B['S'])
	W_ct['R'] = min(A['P'], B['R'])
	W_ct['P'] = min(A['S'], B['P'])
	return W_ct

def check(A, B, n):
	W_ct = won(A, B)
	k = sum(W_ct.values())
	if k >= ceil(n / 2):
		return (True, W_ct)
	return (False, W_ct)

def gen(seq_B, A, B, W_ct, n):
	seq_A = ['_'] * n
	for (idx, sym) in enumerate(seq_B):
		if W_ct[sym] > 0:
			seq_A[idx] = W[sym]
			W_ct[sym] -= 1
			A[W[sym]] -= 1
	empty = [idx for (idx, sym) in enumerate(seq_A) if sym == '_']
	for idx in empty:
		for (k, v) in A.items():
			if A[k] != 0:
				seq_A[idx] = k
				A[k] -= 1
				break
	return seq_A

def fill(B):
	s = 'RPS'
	for sym in s:
		B[sym] = 0 if sym not in B else B[sym]

def Alice(a, b, c):
	A = {'R': a, 'P': b, 'S': c}
	return A

def Bob(s):
	B = Counter(s)
	fill(B)
	return B
t = int(input())
ans = []
for _ in range(t):
	n = int(input())
	(a, b, c) = atoi(sys.stdin.readline())
	A = Alice(a, b, c)
	s = sys.stdin.readline().rstrip()
	B = Bob(s)
	(is_w, W_ct) = check(A, B, n)
	if not is_w:
		ans.append('NO')
		continue
	seq_A = gen(s, A, B, W_ct, n)
	ans.append('YES')
	ans.append(''.join(seq_A))
print(*ans, sep='\n')


t = int(input())
for _ in range(t):
	n = int(input())
	(rock, paper, scissor) = map(int, input().split())
	s = input()
	d = {'R': 0, 'P': 0, 'S': 0}
	for ch in s:
		d[ch] += 1
	poss_wins = min(d['R'], paper) + min(d['S'], rock) + min(d['P'], scissor)
	if 2 * poss_wins >= n:
		print('YES')
		ans = []
		for ch in s:
			if ch == 'R':
				if paper > 0:
					paper -= 1
					ans.append('P')
				else:
					ans.append('_')
			elif ch == 'S':
				if rock > 0:
					rock -= 1
					ans.append('R')
				else:
					ans.append('_')
			elif scissor > 0:
				scissor -= 1
				ans.append('S')
			else:
				ans.append('_')
		s_ans = ''
		for ch in ans:
			if ch == '_':
				if paper > 0:
					s_ans += 'P'
					paper -= 1
				elif scissor > 0:
					s_ans += 'S'
					scissor -= 1
				elif rock > 0:
					s_ans += 'R'
					rock -= 1
			else:
				s_ans += ch
		print(s_ans)
	else:
		print('NO')


for i in range(int(input())):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	r = [0] * n
	d = {'R': a, 'P': b, 'S': c}
	for i in range(n):
		if s[i] == 'R' and d['P']:
			d['P'] -= 1
			r[i] = 'P'
		if s[i] == 'P' and d['S']:
			d['S'] -= 1
			r[i] = 'S'
		if s[i] == 'S' and d['R']:
			d['R'] -= 1
			r[i] = 'R'
	if r.count(0) > n // 2:
		print('NO')
	else:
		for i in range(n):
			if r[i] == 0:
				if d['R']:
					r[i] = 'R'
					d['R'] -= 1
				elif d['P']:
					r[i] = 'P'
					d['P'] -= 1
				elif d['S']:
					r[i] = 'S'
					d['S'] -= 1
		print('YES')
		print(''.join(r))


from math import gcd
for _ in range(0, int(input())):
	play = int(input())
	(piedra, papel, tijeras) = [int(x) for x in input().split()]
	(p1, p2, p3) = (0, 0, 0)
	jugada = input()
	for i in jugada:
		if i == 'R':
			p1 += 1
		if i == 'P':
			p2 += 1
		if i == 'S':
			p3 += 1
	total = 0
	m = 0
	if play % 2 == 0:
		m = int(play / 2)
	else:
		m = int(play / 2) + 1
	a = min(p3, piedra)
	b = min(p2, tijeras)
	c = min(p1, papel)
	if a + b + c >= m:
		print('YES')
	else:
		print('NO')
		continue
	rp1 = a
	rp2 = b
	rp3 = c
	piedra -= rp1
	papel -= rp3
	tijeras -= rp2
	ret = ''
	for i in jugada:
		if i == 'R':
			if rp3 > 0:
				ret += 'P'
				rp3 -= 1
			elif papel > 0:
				ret += 'P'
				papel -= 1
			elif piedra > 0:
				ret += 'R'
				piedra -= 1
			else:
				ret += 'S'
				tijeras -= 1
		if i == 'P':
			if rp2 > 0:
				ret += 'S'
				rp2 -= 1
			elif papel > 0:
				ret += 'P'
				papel -= 1
			elif piedra > 0:
				ret += 'R'
				piedra -= 1
			else:
				ret += 'S'
				tijeras -= 1
		if i == 'S':
			if rp1 > 0:
				ret += 'R'
				rp1 -= 1
			elif papel > 0:
				ret += 'P'
				papel -= 1
			elif piedra > 0:
				ret += 'R'
				piedra -= 1
			else:
				ret += 'S'
				tijeras -= 1
	print(ret)


import random

def get_many_ints():
	return map(int, input().split())

def get_int():
	return int(input())

def prog():
	N = get_int()
	(r, p, s) = get_many_ints()
	B = input()
	(_r, _p, _s) = (B.count('R'), B.count('P'), B.count('S'))
	(Ar, Ap, As) = (min(r, _s), min(p, _r), min(s, _p))
	if Ar + Ap + As < (N + 1) // 2:
		print('NO')
		return
	r -= Ar
	p -= Ap
	s -= As
	S = 'R' * r + 'P' * p + 'S' * s
	num = 0
	res = ''
	for i in range(N):
		if B[i] == 'R' and Ap > 0:
			res += 'P'
			Ap -= 1
		elif B[i] == 'P' and As > 0:
			res += 'S'
			As -= 1
		elif B[i] == 'S' and Ar > 0:
			res += 'R'
			Ar -= 1
		else:
			res += S[num]
			num += 1
	print('YES\n' + res)
T = get_int()
for _ in range(T):
	prog()


kkk = int(input())
for kk in range(0, kkk):
	n = int(input())
	x = input().split()
	R = int(x[0])
	P = int(x[1])
	S = int(x[2])
	R_B = 0
	P_B = 0
	S_B = 0
	x = input()
	for i in range(0, len(x)):
		if x[i] == 'R':
			R_B = R_B + 1
		if x[i] == 'P':
			P_B = P_B + 1
		if x[i] == 'S':
			S_B = S_B + 1
	total_win = min(R, S_B) + min(P, R_B) + min(S, P_B)
	if total_win >= n / 2.0:
		print('YES')
		answer = []
		for i in range(0, len(x)):
			if x[i] == 'R' and P > 0:
				answer.append('P')
				P = P - 1
			elif x[i] == 'P' and S > 0:
				answer.append('S')
				S = S - 1
			elif x[i] == 'S' and R > 0:
				answer.append('R')
				R = R - 1
			else:
				answer.append('X')
		for i in range(0, len(x)):
			if answer[i] == 'X':
				if S > 0:
					answer[i] = 'S'
					S = S - 1
				elif R > 0:
					answer[i] = 'R'
					R = R - 1
				else:
					answer[i] = 'P'
					P = P - 1
		final_ans = ''
		for i in range(0, len(answer)):
			final_ans += answer[i]
		print(final_ans)
	else:
		print('NO')


import math
for i in range(int(input())):
	n = int(input())
	(ra, pb, sc) = map(int, input().split())
	s = input()
	al = 0
	ans = [''] * n
	for i in range(n):
		mov = s[i]
		if mov == 'R':
			if pb > 0:
				pb -= 1
				al += 1
				ans[i] = 'P'
		elif mov == 'P':
			if sc > 0:
				sc -= 1
				al += 1
				ans[i] = 'S'
		elif mov == 'S':
			if ra > 0:
				al += 1
				ans[i] = 'R'
				ra -= 1
	if al < math.ceil(n / 2):
		print('NO')
		continue
	print('YES')
	for i in range(n):
		if ans[i] == '' and ra > 0:
			ans[i] = 'R'
			ra -= 1
		elif ans[i] == '' and pb > 0:
			ans[i] = 'P'
			pb -= 1
		elif ans[i] == '' and sc > 0:
			ans[i] = 'S'
			sc -= 1
	print(''.join(ans))


t = int(input())
for i in range(t):
	n = int(input())
	(r, p, s) = map(int, input().split())
	S = input()
	Pob = 0
	ans = []
	for j in range(n):
		el = S[j]
		if el == 'R' and p != 0:
			Pob += 1
			p -= 1
			ans.append('P')
		elif el == 'P' and s != 0:
			Pob += 1
			s -= 1
			ans.append('S')
		elif el == 'S' and r != 0:
			Pob += 1
			r -= 1
			ans.append('R')
		else:
			ans += ' '
	if Pob * 2 < n:
		print('NO')
	else:
		print('YES')
		for k in range(n):
			if ans[k] == ' ':
				if r != 0:
					ans[k] = 'R'
					r -= 1
				elif p != 0:
					ans[k] = 'P'
					p -= 1
				else:
					ans[k] = 'S'
					s -= 1
		print(''.join(ans))


wd = {'R': 'P', 'P': 'S', 'S': 'R'}
ld = {'R': 'S', 'P': 'R', 'S': 'P'}
tc = int(input())
for i in range(tc):
	n = int(input())
	(a, b, c) = list(map(int, input().split()))
	ad = {'R': a, 'P': b, 'S': c}
	bd = {'R': 0, 'P': 0, 'S': 0}
	bseq = input()
	for k in bseq:
		bd[k] += 1
	ald = {k: max(0, ad[k] - bd[ld[k]]) for k in bd}
	if sum(ald.values()) > n // 2:
		print('NO')
		continue
	print('YES')
	aseq = []
	for k in bseq:
		w = wd[k]
		if ad[w] > 0:
			aseq.append(w)
			ad[w] -= 1
			continue
		x = k if ald[k] > 0 else ld[k]
		aseq.append(x)
		ad[x] -= 1
		ald[x] -= 1
	print(''.join(aseq))


t = int(input())
for i in range(0, t):
	n = int(input())
	ln = [int(j) for j in input().split(' ')]
	arr = ['S', 'R', 'P']
	ta = ['R', 'P', 'S']
	ta2 = ['R', 'P', 'S']
	sm = [0, 0, 0]
	s = input()
	st = ''
	for j in s:
		rp = arr.index(j)
		if sm[rp] < ln[rp]:
			st += ta2[rp]
			sm[rp] += 1
		else:
			st += '_'
	sms = 0
	for j in range(0, len(sm)):
		sms += min(ln[j], sm[j])
	w = False
	if n % 2 == 0 and sms >= n // 2:
		w = True
	elif n % 2 != 0 and sms >= n // 2 + 1:
		w = True
	if not w:
		print('NO')
	else:
		print('YES')
		st = list(st)
		for j in range(0, len(st)):
			if st[j] == '_':
				k = 0
				while sm[k] >= ln[k]:
					k += 1
				sm[k] += 1
				st[j] = ta[k]
		print(''.join(st))


from math import *
t = int(input())
for i in range(t):
	n = int(input())
	inp = input()
	inp_arr = inp.split(' ')
	inp_arr = [int(j) for j in inp_arr]
	R = inp_arr[0]
	P = inp_arr[1]
	S = inp_arr[2]
	count = 0
	out_arr = []
	inp_1 = input()
	for j in inp_1:
		if j == 'R' and P > 0:
			P -= 1
			out_arr.append('P')
			count += 1
		elif j == 'P' and S > 0:
			S -= 1
			out_arr.append('S')
			count += 1
		elif j == 'S' and R > 0:
			R -= 1
			out_arr.append('R')
			count += 1
		else:
			out_arr.append(-1)
	if count >= ceil(n / 2):
		u = 0
		while R > 0 and u < n:
			if out_arr[u] == -1:
				out_arr[u] = 'R'
				R -= 1
			u += 1
		u = 0
		while S > 0 and u < n:
			if out_arr[u] == -1:
				out_arr[u] = 'S'
				S -= 1
			u += 1
		u = 0
		while P > 0 and u < n:
			if out_arr[u] == -1:
				out_arr[u] = 'P'
				P -= 1
			u += 1
		out = ''.join(out_arr)
		print('YES')
		print(out)
	else:
		print('NO')


t = int(input())
import math
for i in range(t):
	n = int(input())
	(a, b, c) = list(map(int, input().split()))
	g = input()
	r = g.count('R')
	p = g.count('P')
	s = g.count('S')
	x = min(a, s) + min(p, c) + min(r, b)
	if x >= math.ceil(n / 2):
		print('YES')
		ans = []
		j = 0
		while j < n:
			if g[j] == 'R' and b > 0:
				ans += 'P'
				b -= 1
			elif g[j] == 'P' and c > 0:
				ans += 'S'
				c -= 1
			elif g[j] == 'S' and a > 0:
				ans += 'R'
				a -= 1
			else:
				ans += 'X'
			j += 1
		j = 0
		while a != 0:
			if ans[j] == 'X':
				ans[j] = 'R'
				a -= 1
			j += 1
		while b != 0:
			if ans[j] == 'X':
				ans[j] = 'P'
				b -= 1
			j += 1
		while c != 0:
			if ans[j] == 'X':
				ans[j] = 'S'
				c -= 1
			j += 1
		print(''.join(ans))
	else:
		print('NO')


a = int(input())
for i in range(a):
	n = int(input())
	b = list(map(int, input().strip().split(' ')))
	s = input()
	if 2 * (min(s.count('R'), b[1]) + min(s.count('P'), b[2]) + min(s.count('S'), b[0])) >= n:
		print('YES')
		s = s.replace('R', 'B').replace('P', 'Z').replace('S', 'L')
		s = s.replace('L', 'R').replace('B', 'P').replace('Z', 'S')
		s = list(s)
		j = 0
		while s.count('R') > b[0]:
			if s[j] == 'R':
				s[j] = 'Z'
			j += 1
		j = 0
		while s.count('P') > b[1]:
			if s[j] == 'P':
				s[j] = 'Z'
			j += 1
		j = 0
		while s.count('S') > b[2]:
			if s[j] == 'S':
				s[j] = 'Z'
			j += 1
		j = 0
		while s.count('R') - b[0] != 0:
			if s[j] == 'Z':
				s[j] = 'R'
			j += 1
		while s.count('P') - b[1] != 0:
			if s[j] == 'Z':
				s[j] = 'P'
			j += 1
		while s.count('S') - b[2] != 0:
			if s[j] == 'Z':
				s[j] = 'S'
			j += 1
		print(''.join(s))
	else:
		print('NO')


from math import ceil
t = int(input())
for i in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	x = input()
	r = x.count('R')
	p = x.count('P')
	s = x.count('S')
	dicti = {}
	dicti['R'] = 0
	dicti['P'] = 0
	dicti['S'] = 0
	result = x[:]
	score = 0
	if a - s >= 0:
		score += s
		dicti['R'] += s
		result = result.replace('S', 'r', s)
		a -= s
		s = 0
	else:
		dicti['R'] += a
		result = result.replace('S', 'r', a)
		score += a
		a = 0
		s -= a
	if b - r >= 0:
		dicti['P'] += r
		result = result.replace('R', 'p', r)
		score += r
		b -= r
		r = 0
	else:
		dicti['P'] += b
		result = result.replace('R', 'p', b)
		score += b
		b = 0
		r -= b
	if c - p >= 0:
		dicti['S'] += p
		result = result.replace('P', 's', p)
		score += p
		c -= p
		p = 0
	else:
		dicti['S'] += c
		result = result.replace('P', 's', c)
		score += c
		c = 0
		p -= c
	ans = ''
	for k in result:
		if k.lower() == k:
			ans += k.upper()
		elif a > 0:
			ans += 'R'
			a -= 1
		elif b > 0:
			ans += 'P'
			b -= 1
		elif c > 0:
			ans += 'S'
			c -= 1
	if score >= ceil(n / 2):
		print('YES')
		print(ans)
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	t = ['X'] * n
	wins = 0
	for (i, en) in enumerate(s):
		if en == 'R' and b:
			b -= 1
			t[i] = 'P'
			wins += 1
		elif en == 'P' and c:
			c -= 1
			t[i] = 'S'
			wins += 1
		elif en == 'S' and a:
			a -= 1
			t[i] = 'R'
			wins += 1
	if wins < n / 2:
		print('NO')
	else:
		print('YES')
		for (i, my) in enumerate(t):
			if my == 'X':
				if a:
					a -= 1
					t[i] = 'R'
				elif b:
					b -= 1
					t[i] = 'P'
				elif c:
					c -= 1
					t[i] = 'S'
		print(''.join(t))


def fun():
	global a, b, c, s, n
	res = [''] * n
	sum_ = 0
	for i in range(n):
		if s[i] == 'R' and b > 0:
			sum_ += 1
			res[i] = 'P'
			b -= 1
		elif s[i] == 'P' and c > 0:
			sum_ += 1
			res[i] = 'S'
			c -= 1
		elif s[i] == 'S' and a > 0:
			sum_ += 1
			res[i] = 'R'
			a -= 1
	if sum_ < (n + 1) // 2:
		print('no')
		return
	for i in range(n):
		if res[i] == '':
			if a > 0:
				res[i] = 'R'
				a -= 1
			elif b > 0:
				res[i] = 'P'
				b -= 1
			else:
				res[i] = 'S'
				c -= 1
	print('yes')
	for i in range(n):
		print(res[i], end='')
	print()
t = int(input())
for _ in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	fun()


Q = int(input())
Query = []
for _ in range(Q):
	N = int(input())
	(A, B, C) = map(int, input().split())
	S = input()
	Query.append((N, A, B, C, S))
for (N, A, B, C, S) in Query:
	dic = {'R': A, 'P': B, 'S': C}
	ans = []
	for i in range(N):
		if S[i] == 'R':
			if dic['P'] > 0:
				dic['P'] -= 1
				ans.append('P')
			else:
				ans.append('W')
		elif S[i] == 'P':
			if dic['S'] > 0:
				dic['S'] -= 1
				ans.append('S')
			else:
				ans.append('W')
		elif dic['R'] > 0:
			dic['R'] -= 1
			ans.append('R')
		else:
			ans.append('W')
	if ans.count('W') > N // 2:
		print('NO')
	else:
		print('YES')
		for i in range(N):
			if ans[i] == 'W':
				if dic['P'] > 0:
					dic['P'] -= 1
					ans[i] = 'P'
				elif dic['R'] > 0:
					dic['R'] -= 1
					ans[i] = 'R'
				else:
					dic['S'] -= 1
					ans[i] = 'S'
		print(''.join(ans))


from collections import Counter
t = int(input())
for _ in range(t):
	n = int(input())
	need = (n + 1) // 2
	disp = [int(i) for i in input().split()]
	ganha = {'R': 1, 'P': 2, 'S': 0}
	dic = {0: 'R', 1: 'P', 2: 'S'}
	jog = input()
	res = []
	i = 0
	while i < len(jog):
		if need and disp[ganha[jog[i]]]:
			disp[ganha[jog[i]]] -= 1
			res.append(dic[ganha[jog[i]]])
			need -= 1
		else:
			res.append('*')
		i += 1
	if need == 0:
		print('YES')
		for i in res:
			if i != '*':
				print(i, end='')
			elif disp[0]:
				print('R', end='')
				disp[0] -= 1
			elif disp[1]:
				print('P', end='')
				disp[1] -= 1
			elif disp[2]:
				print('S', end='')
				disp[2] -= 1
		print()
	else:
		print('NO')


from math import ceil
for _ in range(int(input())):
	N = int(input())
	X = list(map(int, input().split()))
	AliceDict = {'R': X[0], 'P': X[1], 'S': X[2]}
	BobMove = input()
	(Win, Answer) = (0, ['0'] * N)
	for i in range(N):
		if BobMove[i] == 'R':
			Answer[i] = 'P' if AliceDict['P'] > 0 else '0'
			AliceDict['P'] -= 1
		if BobMove[i] == 'P':
			Answer[i] = 'S' if AliceDict['S'] > 0 else '0'
			AliceDict['S'] -= 1
		if BobMove[i] == 'S':
			Answer[i] = 'R' if AliceDict['R'] > 0 else '0'
			AliceDict['R'] -= 1
	if N - Answer.count('0') < ceil(N / 2):
		print('NO')
		continue
	print('YES')
	Left = ''.join((key * AliceDict[key] for key in AliceDict))
	for i in range(N):
		if Answer[i] == '0':
			Answer[i] = Left[-1]
			Left = Left[:-1]
	print(*Answer, sep='')


for i in range(int(input())):
	(n, a, s) = (int(input()), [int(i) for i in input().split()], input())
	b = [s.count('R'), s.count('P'), s.count('S')]
	s = [i for i in s]
	if min(a[0], b[2]) + min(a[1], b[0]) + min(a[2], b[1]) >= (n + 1) // 2:
		print('YES')
		w = [False] * n
		for i in range(min(a[0], b[2])):
			i = s.index('S')
			(w[i], s[i]) = ('R', False)
		a[0] -= min(a[0], b[2])
		for i in range(min(a[1], b[0])):
			i = s.index('R')
			(w[i], s[i]) = ('P', False)
		a[1] -= min(a[1], b[0])
		for i in range(min(a[2], b[1])):
			i = s.index('P')
			(w[i], s[i]) = ('S', False)
		a[2] -= min(a[2], b[1])
		for i in range(a[0]):
			w[w.index(False)] = 'R'
		for i in range(a[1]):
			w[w.index(False)] = 'P'
		for i in range(a[2]):
			w[w.index(False)] = 'S'
		print(''.join(w))
	else:
		print('NO')


from collections import Counter
import math
winner = {'R': 'P', 'S': 'R', 'P': 'S'}
(R, S, P) = ('R', 'S', 'P')

def solve(n, a, b, c, s):
	me = {R: a, P: b, S: c}
	opposite = Counter(s)
	if sum((min(me[winner[k]], v) for (k, v) in opposite.items())) < math.ceil(n / 2):
		return None
	seq = [None] * n
	for (i, e) in enumerate(s):
		win = winner[e]
		if me[win] > 0:
			me[win] -= 1
			seq[i] = win
	for (i, e) in enumerate(s):
		if not seq[i]:
			for k in me.keys():
				if me[k] > 0:
					me[k] -= 1
					seq[i] = k
					break
	return ''.join(seq)
for _ in range(int(input())):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	r = solve(n, a, b, c, s)
	if not r:
		print('NO')
	else:
		print('YES')
		print(r)


import math
t = int(input())
for i in range(t):
	n = int(input())
	(a, b, c) = list(map(int, input().strip().split()))
	d = input()
	r = d.count('R')
	p = d.count('P')
	s = d.count('S')
	e = min(a, s)
	f = min(b, r)
	g = min(c, p)
	n1 = math.ceil(n / 2)
	arr = [0] * n
	if e + f + g >= n1:
		print('YES')
		for j in range(n):
			if d[j] == 'R' and b > 0:
				arr[j] = 'P'
				b = b - 1
			elif d[j] == 'P' and c > 0:
				arr[j] = 'S'
				c = c - 1
			elif d[j] == 'S' and a > 0:
				arr[j] = 'R'
				a = a - 1
		for j in range(n):
			if arr[j] == 0:
				if a > 0:
					arr[j] = 'R'
					a = a - 1
				elif b > 0:
					arr[j] = 'P'
					b = b - 1
				elif c > 0:
					arr[j] = 'S'
					c = c - 1
		print(''.join(arr))
	else:
		print('NO')


from math import ceil
for _ in range(int(input())):
	n = int(input())
	(a, b, c) = map(int, input().split())
	(ba, bb, bc) = (0, 0, 0)
	s = input()
	dp = ['' for i in range(len(s))]
	for i in s:
		if i == 'R':
			bb += 1
		elif i == 'P':
			bc += 1
		else:
			ba += 1
	if min(a, ba) + min(b, bb) + min(c, bc) >= ceil(n / 2):
		print('YES')
		for i in range(len(s)):
			if s[i] == 'R' and b:
				b -= 1
				dp[i] = 'P'
			elif s[i] == 'P' and c:
				c -= 1
				dp[i] = 'S'
			elif s[i] == 'S' and a:
				a -= 1
				dp[i] = 'R'
		for i in dp:
			if i:
				print(i, end='')
			elif a:
				a -= 1
				print('R', end='')
			elif b:
				b -= 1
				print('P', end='')
			elif c:
				c -= 1
				print('S', end='')
		print()
	else:
		print('NO')


import math
t = int(input())
for T in range(t):
	n = int(input())
	x = input()
	(a, b, c) = x.split(' ')
	a = int(a)
	b = int(b)
	c = int(c)
	s = input()
	nr = 0
	np = 0
	ns = 0
	for i in s:
		if i == 'R':
			nr = nr + 1
		elif i == 'P':
			np = np + 1
		else:
			ns = ns + 1
	l = []
	j = 0
	if min(nr, b) + min(np, c) + min(ns, a) >= math.ceil(n / 2):
		for i in s:
			if i == 'R':
				if b > 0:
					l.append('P')
					b = b - 1
				else:
					l.append('')
			elif i == 'P':
				if c > 0:
					l.append('S')
					c = c - 1
				else:
					l.append('')
			elif i == 'S':
				if a > 0:
					l.append('R')
					a = a - 1
				else:
					l.append('')
		for i in range(len(l)):
			if l[i] == '':
				if a > 0:
					l[i] = 'R'
					a = a - 1
				elif b > 0:
					l[i] = 'P'
					b = b - 1
				else:
					l[i] = 'S'
					c = c - 1
		print('YES')
		for i in range(len(l) - 1):
			print(l[i], end='')
		print(l[-1])
	else:
		print('NO')


import math
for _ in range(int(input())):
	n = int(input())
	(r, p, s) = map(int, input().split())
	seq = input()
	ans = ['_' for i in range(len(seq))]
	for (i, ele) in enumerate(seq):
		if ele == 'R':
			if p > 0:
				ans[i] = 'P'
				p -= 1
		elif ele == 'P':
			if s > 0:
				ans[i] = 'S'
				s -= 1
		elif r > 0:
			ans[i] = 'R'
			r -= 1
	if n - ans.count('_') >= (n + 1) // 2:
		print('YES')
		for ele in ans:
			if ele != '_':
				print(ele, end='')
			elif r > 0:
				print('R', end='')
				r -= 1
			elif p > 0:
				print('P', end='')
				p -= 1
			else:
				print('S', end='')
				s -= 1
		print()
	else:
		print('NO')


T = int(input())
for t in range(T):
	n = int(input())
	(a, b, c) = [int(i) for i in input().split()]
	ss = input()
	r = a
	p = b
	s = c
	wins = 0
	losses = 0
	seq = ['0' for i in range(n)]
	for i in range(n):
		if ss[i] == 'R':
			if p > 0:
				seq[i] = 'P'
				p -= 1
				wins += 1
		if ss[i] == 'S':
			if r > 0:
				seq[i] = 'R'
				r -= 1
				wins += 1
		if ss[i] == 'P':
			if s > 0:
				seq[i] = 'S'
				s -= 1
				wins += 1
	for i in range(n):
		if seq[i] == '0':
			if ss[i] == 'R':
				if r > 0:
					seq[i] = 'R'
					r -= 1
				elif s > 0:
					s -= 1
					seq[i] = 'S'
			elif ss[i] == 'P':
				if p > 0:
					seq[i] = 'P'
					p -= 1
				elif r > 0:
					seq[i] = 'R'
					r -= 1
			elif ss[i] == 'S':
				if s > 0:
					seq[i] = 'S'
					s -= 1
				elif p > 0:
					seq[i] = 'P'
					p -= 1
	if wins >= (n + 1) // 2:
		print('YES')
		print(''.join(seq))
	else:
		print('NO')


test_cases = int(input())
record_integers = [1, 2, 3]
record_pattern = None
for i in range(test_cases):
	n = int(input())
	(record_integers[0], record_integers[1], record_integers[2]) = input().split()
	record_pattern = str(input())
	R = record_pattern.count('R')
	P = record_pattern.count('P')
	S = record_pattern.count('S')
	record_integers[0] = int(record_integers[0])
	record_integers[1] = int(record_integers[1])
	record_integers[2] = int(record_integers[2])
	P_win = min(R, record_integers[1])
	S_win = min(P, record_integers[2])
	R_win = min(S, record_integers[0])
	total = P_win + S_win + R_win
	if total >= n - total:
		print('YES')
		winning_pattern = ['a'] * len(record_pattern)
		for i in range(len(record_pattern)):
			if record_pattern[i] == 'R' and record_integers[1] > 0:
				winning_pattern[i] = 'P'
				record_integers[1] -= 1
			elif record_pattern[i] == 'P' and record_integers[2] > 0:
				winning_pattern[i] = 'S'
				record_integers[2] -= 1
			elif record_pattern[i] == 'S' and record_integers[0] > 0:
				winning_pattern[i] = 'R'
				record_integers[0] -= 1
		for i in range(len(record_pattern)):
			if winning_pattern[i] == 'a':
				if record_integers[0] > 0:
					winning_pattern[i] = 'R'
					record_integers[0] -= 1
				elif record_integers[1] > 0:
					winning_pattern[i] = 'P'
					record_integers[1] -= 1
				elif record_integers[2] > 0:
					winning_pattern[i] = 'S'
					record_integers[2] -= 1
		print(''.join(winning_pattern))
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	ans = ''
	d = {'R': 0, 'P': 0, 'S': 0}
	for i in range(n):
		if s[i] == 'R':
			ans += 'P'
		elif s[i] == 'P':
			ans += 'S'
		elif s[i] == 'S':
			ans += 'R'
		d[ans[-1]] += 1
	count = 0
	count += min(d['R'], a)
	count += min(d['P'], b)
	count += min(d['S'], c)
	if count >= n / 2:
		print('yes')
		ans = list(ans)
		over = []
		under = []
		if d['R'] > a:
			over.append('R')
		if d['R'] < a:
			under.append('R')
		if d['P'] > b:
			over.append('P')
		if d['P'] < b:
			under.append('P')
		if d['S'] > c:
			over.append('S')
		if d['S'] < c:
			under.append('S')

		def match(char):
			if char == 'R':
				return a
			if char == 'P':
				return b
			if char == 'S':
				return c
		if over and under:
			for i in range(n):
				if ans[i] in over and d[ans[i]] > match(ans[i]):
					d[ans[i]] -= 1
					d[under[0]] += 1
					ans[i] = under[0]
					if d[under[0]] == match(under[0]):
						under.pop(0)
		elif over:
			if 'R' not in d:
				missing = 'R'
			elif 'P' not in d:
				missing = 'P'
			else:
				missing = 'S'
			for i in range(n):
				if ans[i] in over and d[ans[i]] > match(ans[i]):
					d[ans[i]] -= 1
					d[missing] += 1
					ans[i] = missing
		print(''.join(ans))
	else:
		print('no')


(z, zz) = (input, lambda : list(map(int, z().split())))
zzz = lambda : [int(i) for i in stdin.readline().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
d = {'R': 'P', 'P': 'S', 'S': 'R'}
num = int(z())
for _ in range(num):
	n = int(z())
	(a, b, c) = zzz()
	win = 0
	l = z()
	ans = ''
	for i in l:
		if i == 'R' and b >= 1:
			b -= 1
			win += 1
			ans += 'P'
		elif i == 'P' and c >= 1:
			win += 1
			c -= 1
			ans += 'S'
		elif i == 'S' and a >= 1:
			win += 1
			ans += 'R'
			a -= 1
		else:
			ans += '.'
	for i in ans:
		if i == '.' and a >= 1:
			a -= 1
			ans = ans.replace('.', 'R', 1)
		elif i == '.' and b >= 1:
			b -= 1
			ans = ans.replace('.', 'P', 1)
		elif i == '.' and c >= 1:
			c -= 1
			ans = ans.replace('.', 'S', 1)
	if win >= ceil(n / 2):
		print('YES')
		print(ans)
	else:
		print('NO')


import math
for w in range(int(input())):
	n = int(input())
	(a, b, c) = tuple(map(int, input().split()))
	s = str(input())
	a1 = s.count('S')
	b1 = s.count('R')
	c1 = s.count('P')
	ans = 0
	ans += min(a, a1) + min(b, b1) + min(c, c1)
	if ans >= math.ceil(n / 2):
		print('YES')
		l = [0] * n
		i = 0
		while a > 0 and i < n:
			if s[i] == 'S':
				l[i] = 'R'
				a -= 1
			i += 1
		i = 0
		while b > 0 and i < n:
			if s[i] == 'R':
				l[i] = 'P'
				b -= 1
			i += 1
		i = 0
		while c > 0 and i < n:
			if s[i] == 'P':
				l[i] = 'S'
				c -= 1
			i += 1
		i = 0
		while i < n:
			if l[i] == 0:
				if a > 0:
					l[i] = 'R'
					a -= 1
				elif b > 0:
					l[i] = 'P'
					b -= 1
				elif c > 0:
					l[i] = 'S'
					c -= 1
			i += 1
		print(''.join(l))
	else:
		print('NO')


c = int(input())
for k in range(c):
	n = int(input())
	val = [int(i) for i in input().split()]
	seq = input()
	wins = 0
	seq2 = [0] * n
	for i in range(n):
		if seq[i] == 'R':
			if val[1] > 0:
				val[1] -= 1
				wins += 1
				seq2[i] = 'P'
		if seq[i] == 'P':
			if val[2] > 0:
				val[2] -= 1
				wins += 1
				seq2[i] = 'S'
		if seq[i] == 'S':
			if val[0] > 0:
				val[0] -= 1
				wins += 1
				seq2[i] = 'R'
	if wins * 2 >= n:
		for i in range(n):
			if seq2[i] == 0:
				if val[0] > 0:
					seq2[i] = 'R'
					val[0] -= 1
				elif val[1] > 0:
					seq2[i] = 'P'
					val[1] -= 1
				else:
					seq2[i] = 'S'
					val[2] -= 1
		print('YES')
		for char in seq2:
			print(char, end='')
		print('')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	(a, b, c) = [int(i) for i in input().split()]
	w = 0
	s1 = ''
	s = input()
	for i in s:
		if i == 'S' and a > 0:
			a -= 1
			w += 1
			s1 += 'R'
		elif i == 'R' and b > 0:
			b -= 1
			w += 1
			s1 += 'P'
		elif i == 'P' and c > 0:
			c -= 1
			w += 1
			s1 += 'S'
		else:
			s1 += '.'
	if w >= n // 2 + n % 2:
		print('YES')
		i1 = 0
		while i1 < len(s1):
			if s1[i1] == '.':
				if a > 0:
					s1 = s1[:i1] + 'R' + s1[i1 + 1:]
					a -= 1
				elif b > 0:
					s1 = s1[:i1] + 'P' + s1[i1 + 1:]
					b -= 1
				elif c > 0:
					s1 = s1[:i1] + 'S' + s1[i1 + 1:]
					c -= 1
			i1 += 1
		print(s1)
	else:
		print('NO')


t = int(input())
for case_num in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split(' '))
	s = input()
	win = 0
	t = ['' for i in s]
	for i in range(len(s)):
		if s[i] == 'R' and b > 0:
			t[i] = 'P'
			b -= 1
			win += 1
		if s[i] == 'P' and c > 0:
			t[i] = 'S'
			c -= 1
			win += 1
		if s[i] == 'S' and a > 0:
			t[i] = 'R'
			a -= 1
			win += 1
	if win < (n + 1) // 2:
		print('NO')
	else:
		for i in range(len(s)):
			if t[i] == '':
				if a > 0:
					t[i] = 'R'
					a -= 1
				elif b > 0:
					t[i] = 'P'
					b -= 1
				elif c > 0:
					t[i] = 'S'
					c -= 1
		print('YES')
		print(''.join(t))


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	s = list(str(input()))
	u = min(s.count('P'), arr[2]) + min(s.count('R'), arr[1]) + min(s.count('S'), arr[0])
	if u * 2 < n:
		print('NO')
	else:
		print('YES')
		d = [0] * n
		for j in range(n):
			if s[j] == 'S':
				if arr[0] != 0:
					d[j] = 'R'
					arr[0] -= 1
			elif s[j] == 'R':
				if arr[1] != 0:
					arr[1] -= 1
					d[j] = 'P'
			elif arr[2] != 0:
				arr[2] -= 1
				d[j] = 'S'
		f = 'R' * arr[0] + 'P' * arr[1] + 'S' * arr[2]
		f = list(f)
		for j in range(len(d)):
			if d[j] == 0:
				d[j] = f[0]
				del f[0]
		print(''.join(d))


import math
t = int(input())
for _ in range(t):
	n = int(input())
	m = math.ceil(n / 2)
	(a, b, c) = [int(x) for x in input().split()]
	seq = input()
	Rnum = 0
	Pnum = 0
	Snum = 0
	for t in seq:
		if t == 'R':
			Rnum += 1
		elif t == 'P':
			Pnum += 1
		else:
			Snum += 1
	win = min(a, Snum) + min(b, Rnum) + min(c, Pnum)
	if win < m:
		print('NO')
	else:
		print('YES')
		alice = []
		mR = min(b, Rnum)
		mP = min(c, Pnum)
		mS = min(a, Snum)
		for t in seq:
			if t == 'R':
				if mR > 0:
					mR -= 1
					b -= 1
					alice += 'P'
				else:
					alice += 'K'
			elif t == 'P':
				if mP > 0:
					mP -= 1
					c -= 1
					alice += 'S'
				else:
					alice += 'K'
			elif mS > 0:
				mS -= 1
				a -= 1
				alice += 'R'
			else:
				alice += 'K'
		remain = []
		for _ in range(b):
			remain += ['P']
		for _ in range(c):
			remain += ['S']
		for _ in range(a):
			remain += ['R']
		i = 0
		for j in range(len(alice)):
			if alice[j] == 'K':
				alice[j] = remain[i]
				i += 1
				if i == len(alice):
					break
		print(''.join(alice))


from math import ceil
for _ in range(int(input())):
	n = int(input())
	(r, p, s) = map(int, input().split())
	ss = input()
	ch = 0
	ans = ''
	for i in ss:
		if i == 'R':
			if p > 0:
				p -= 1
				ch += 1
				ans += 'P'
			else:
				ans += ' '
		elif i == 'P':
			if s > 0:
				s -= 1
				ch += 1
				ans += 'S'
			else:
				ans += ' '
		elif r > 0:
			r -= 1
			ch += 1
			ans += 'R'
		else:
			ans += ' '
	if ch < ceil(n / 2):
		print('NO')
	else:
		for i in range(len(ans)):
			if ans[i] == ' ':
				if r > 0:
					ans = ans[:i] + 'R' + ans[i + 1:]
					r -= 1
				elif p > 0:
					ans = ans[:i] + 'P' + ans[i + 1:]
					p -= 1
				else:
					ans = ans[:i] + 'S' + ans[i + 1:]
					s -= 1
		print('YES')
		print(ans)


import math
test = int(input())
for _ in range(test):
	n = int(input())
	(r, p, s) = map(int, input().split())
	string = input()
	count = 0
	arr = []
	for i in string:
		if i == 'R':
			if p > 0:
				p -= 1
				count += 1
				arr.append('P')
			else:
				arr.append('X')
		elif i == 'P':
			if s > 0:
				s -= 1
				count += 1
				arr.append('S')
			else:
				arr.append('X')
		elif i == 'S':
			if r > 0:
				r -= 1
				count += 1
				arr.append('R')
			else:
				arr.append('X')
	if count >= math.ceil(n / 2):
		print('YES')
		for i in range(n):
			if arr[i] == 'X':
				if r > 0:
					print('R', end='')
					r -= 1
				elif p > 0:
					print('P', end='')
					p -= 1
				elif s > 0:
					print('S', end='')
					s -= 1
			else:
				print(arr[i], end='')
		print('')
	else:
		print('NO')


import sys
(q,) = map(int, sys.stdin.readline().split())
for _ in range(q):
	(n,) = map(int, sys.stdin.readline().split())
	(a, b, c) = map(int, sys.stdin.readline().split())
	s = sys.stdin.readline().rstrip()
	(x, y, z) = (s.count('R'), s.count('P'), s.count('S'))
	res = ''
	(wa, wb, wc) = (min(z, a), min(x, b), min(y, c))
	(la, lb, lc) = (a - wa, b - wb, c - wc)
	wins = wa + wb + wc
	if wins >= (n + 1) // 2:
		print('YES')
		for c in s:
			if c == 'R' and wb > 0:
				res += 'P'
				wb -= 1
			elif c == 'P' and wc > 0:
				res += 'S'
				wc -= 1
			elif c == 'S' and wa > 0:
				res += 'R'
				wa -= 1
			elif la > 0:
				res += 'R'
				la -= 1
			elif lb > 0:
				res += 'P'
				lb -= 1
			else:
				assert lc > 0
				res += 'S'
				lc -= 1
		print(res)
	else:
		print('NO')


import math
t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input().strip()
	res = ''
	count = 0
	for i in s:
		if i == 'R':
			if b > 0:
				count += 1
				b -= 1
				res += 'P'
			else:
				res += '-'
		elif i == 'P':
			if c > 0:
				count += 1
				c -= 1
				res += 'S'
			else:
				res += '-'
		elif i == 'S':
			if a > 0:
				count += 1
				a -= 1
				res += 'R'
			else:
				res += '-'
	if count >= math.ceil(n / 2):
		print('YES')
		res = list(res)
		for i in range(n):
			if res[i] == '-':
				if a > 0:
					a -= 1
					res[i] = 'R'
				elif b > 0:
					b -= 1
					res[i] = 'P'
				elif c > 0:
					c -= 1
					res[i] = 'S'
		print(''.join(res))
	else:
		print('NO')


from sys import stdin
from math import ceil
t = int(stdin.readline().strip())
for caso in range(t):
	n = int(stdin.readline().strip())
	s = list(map(int, stdin.readline().strip().split()))
	s1 = stdin.readline().strip()
	ans = ['' for i in range(n)]
	r = 0
	for i in range(n):
		if s1[i] == 'R' and s[1] > 0:
			ans[i] = 'P'
			s[1] -= 1
			r += 1
		elif s1[i] == 'P' and s[2] > 0:
			ans[i] = 'S'
			r += 1
			s[2] -= 1
		elif s1[i] == 'S' and s[0] > 0:
			ans[i] = 'R'
			r += 1
			s[0] -= 1
	for i in range(n):
		if ans[i] == '':
			if s[0] > 0:
				ans[i] = 'R'
				s[0] -= 1
			elif s[1] > 0:
				ans[i] = 'P'
				s[1] -= 1
			else:
				ans[i] = 'S'
				s[2] -= 1
	if r >= ceil(n / 2):
		print('YES')
		res = ''
		for i in range(n):
			res += ans[i]
		print(res)
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	candodge = [0] * n
	game = input()
	cnt = 0
	for i in range(n):
		if game[i] == 'R':
			if b > 0:
				candodge[i] = 1
				b -= 1
				cnt += 1
		elif game[i] == 'P':
			if c > 0:
				candodge[i] = 1
				c -= 1
				cnt += 1
		elif a > 0:
			candodge[i] = 1
			a -= 1
			cnt += 1
	if cnt >= (n + 1) // 2:
		print('yes')
		for i in range(n):
			if game[i] == 'R':
				if candodge[i]:
					print('P', end='')
				elif a > 0:
					print('R', end='')
					a -= 1
				else:
					print('S', end='')
					c -= 1
			elif game[i] == 'P':
				if candodge[i]:
					print('S', end='')
				elif a > 0:
					print('R', end='')
					a -= 1
				else:
					print('P', end='')
					b -= 1
			elif candodge[i]:
				print('R', end='')
			elif b > 0:
				print('P', end='')
				b -= 1
			else:
				print('S', end='')
				c -= 1
	else:
		print('no', end='')
	print()


import sys
import math
t = int(sys.stdin.readline())
for i in range(t):
	n = int(sys.stdin.readline())
	[a, b, c] = [int(i) for i in sys.stdin.readline().split()]
	s = sys.stdin.readline().strip()
	a1 = 0
	b1 = 0
	c1 = 0
	r_ind = []
	p_ind = []
	s_ind = []
	for i in range(n):
		if s[i] == 'R':
			a1 += 1
			r_ind.append(i)
		elif s[i] == 'P':
			b1 += 1
			p_ind.append(i)
		elif s[i] == 'S':
			c1 += 1
			s_ind.append(i)
	r = a - min(a, c1)
	p = b - min(b, a1)
	s = c - min(c, b1)
	thresh = math.ceil(n / 2)
	if min(a, c1) + min(b, a1) + min(c, b1) < thresh:
		print('NO')
	else:
		print('YES')
		ans = []
		for e in range(n):
			ans.append('')
		for g in range(min(a, c1)):
			ans[s_ind[g]] = 'R'
		for h in range(min(b, a1)):
			ans[r_ind[h]] = 'P'
		for w in range(min(c, b1)):
			ans[p_ind[w]] = 'S'
		tmp = r * 'R'
		tmp += p * 'P'
		tmp += s * 'S'
		tind = 0
		for q in range(n):
			if ans[q] == '':
				ans[q] = tmp[tind]
				tind += 1
		print(''.join(ans))


from math import gcd
t = int(input())
while t:
	t -= 1
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	_a = s.count('R')
	_b = s.count('P')
	_c = s.count('S')
	da = min(_c, a)
	db = min(_a, b)
	dc = min(_b, c)
	if da + db + dc >= n // 2 + n % 2:
		print('YES')
		for m in s:
			if m == 'R' and db:
				print('P', end='')
				db -= 1
				b -= 1
			elif m == 'P' and dc:
				print('S', end='')
				dc -= 1
				c -= 1
			elif m == 'S' and da:
				da -= 1
				a -= 1
				print('R', end='')
			elif a > da:
				print('R', end='')
				a -= 1
			elif b > db:
				print('P', end='')
				b -= 1
			else:
				print('S', end='')
				c -= 1
		print('')
	else:
		print('NO')


t = int(input())
while t:
	t -= 1
	n = int(input())
	(rock, paper, sci) = map(int, input().split())
	op = list(input())
	em = ['0'] * n
	i = 0
	c = 0
	while i < n:
		if op[i] == 'R' and paper > 0:
			paper -= 1
			c += 1
			em[i] = 'P'
		elif op[i] == 'P' and sci > 0:
			sci -= 1
			c += 1
			em[i] = 'S'
		elif op[i] == 'S' and rock > 0:
			rock -= 1
			c += 1
			em[i] = 'R'
		i += 1
	if n % 2 == 1:
		rou = int((n + 1) / 2)
	else:
		rou = n / 2
	if c < rou:
		print('NO')
	else:
		i = 0
		while i < n:
			if em[i] == '0':
				if rock > 0:
					em[i] = 'R'
					rock -= 1
				elif paper > 0:
					em[i] = 'P'
					paper -= 1
				elif sci > 0:
					sci -= 1
					em[i] = 'S'
			i += 1
		print('YES')
		print(''.join(em))


import os
import heapq
import sys
import math
from collections import defaultdict
from io import BytesIO, IOBase

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def main():
	for _ in range(int(input())):
		n = int(input())
		(a, b, c) = map(int, input().split())
		st = input()
		lis = [0] * n
		count = 0
		for i in range(n):
			if st[i] == 'R' and b > 0:
				lis[i] = 'P'
				b -= 1
				count += 1
			if st[i] == 'P' and c > 0:
				lis[i] = 'S'
				c -= 1
				count += 1
			if st[i] == 'S' and a > 0:
				lis[i] = 'R'
				a -= 1
				count += 1
		val = 0
		if n % 2 == 0:
			val = n // 2
		else:
			val = n // 2 + 1
		if count >= val:
			for i in range(n):
				if lis[i] == 0:
					if a > 0:
						lis[i] = 'R'
						a -= 1
					elif b > 0:
						lis[i] = 'P'
						b -= 1
					else:
						lis[i] = 'S'
						c -= 1
			print('YES')
			print(''.join(lis))
		else:
			print('NO')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import math
pattern = 'RPS'

def main():
	round = int(input())
	(a, b, c) = list(map(int, input().split()))
	(r, p, s) = (0, 0, 0)
	hands = input()
	for h in hands:
		if h == 'R':
			r += 1
		if h == 'P':
			p += 1
		if h == 'S':
			s += 1
	win = list(map(min, [(a, s), (b, r), (c, p)]))
	strict = list(map(lambda x, y: x - y, (a, b, c), win))
	if sum(win) >= math.ceil(round / 2):
		print('YES')
		ans = [''] * round
		for idx in range(3):
			for (i, h) in enumerate(hands):
				if win[idx] <= 0:
					break
				if h == pattern[(idx + 2) % 3]:
					ans[i] = pattern[idx]
					win[idx] -= 1
		for i in range(round):
			if ans[i] == '':
				for k in range(3):
					if strict[k] > 0:
						strict[k] -= 1
						ans[i] = pattern[k]
						break
		print(''.join(ans))
	else:
		print('NO')
t = int(input())
for i in range(t):
	main()


def arr_inp():
	return [int(x) for x in input().split()]
from collections import *
from math import *
for i in range(int(input())):
	(n, a, t) = (int(input()), arr_inp(), input())
	dic = defaultdict(int, map(lambda x, y: [x, y], ['R', 'P', 'S'], a))
	count = Counter(t)
	(out, c) = ('', 0)
	for (j, k) in enumerate(t):
		if k == 'R':
			if dic['P']:
				out += 'P'
				dic['P'] -= 1
				c += 1
			elif dic['R'] > count['S'] or dic['S'] == 0:
				out += 'R'
				dic['R'] -= 1
			else:
				out += 'S'
				dic['S'] -= 1
			count['R'] -= 1
		elif k == 'P':
			if dic['S']:
				out += 'S'
				dic['S'] -= 1
				c += 1
			elif dic['P'] > count['R'] or dic['R'] == 0:
				out += 'P'
				dic['P'] -= 1
			else:
				out += 'R'
				dic['R'] -= 1
			count['P'] -= 1
		else:
			if dic['R']:
				out += 'R'
				dic['R'] -= 1
				c += 1
			elif dic['S'] > count['P'] or dic['P'] == 0:
				out += 'S'
				dic['S'] -= 1
			else:
				out += 'P'
				dic['P'] -= 1
			count['S'] -= 1
	if c >= ceil(n / 2):
		print('YES', out, sep='\n')
	else:
		print('NO')


ts = int(input())
ans = []

def ceildiv(a, b):
	return -(-a // b)
for t in range(ts):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = list(input())
	an = []
	won = 0
	for i in range(len(s)):
		if s[i] == 'S' and a > 0:
			an.append('R')
			won += 1
			a -= 1
		elif s[i] == 'R' and b > 0:
			an.append('P')
			won += 1
			b -= 1
		elif s[i] == 'P' and c > 0:
			an.append('S')
			won += 1
			c -= 1
		else:
			an.append('_')
	if won >= ceildiv(n, 2):
		for i in range(len(s)):
			if an[i] == '_':
				if a > 0:
					an[i] = 'R'
					a -= 1
				elif b > 0:
					an[i] = 'P'
					b -= 1
				elif c > 0:
					an[i] = 'S'
					c -= 1
		ans.append(('YES', ''.join(an)))
	else:
		ans.append(('NO', ''))
for a in ans:
	print(a[0])
	if a[1] != '':
		print(a[1])


q = int(input())
for _ in range(q):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	rock = s.count('R')
	paper = s.count('P')
	scissors = s.count('S')
	winmax = min(a, scissors) + min(b, rock) + min(c, paper)
	if winmax < (n + 1) // 2:
		print('NO')
	else:
		snew = ''
		for el in s:
			k = True
			if el == 'R' and b > 0:
				snew += 'P'
				b -= 1
				k = False
			if el == 'P' and c > 0:
				snew += 'S'
				c -= 1
				k = False
			if el == 'S' and a > 0:
				snew += 'R'
				a -= 1
				k = False
			if k:
				snew += '0'
		rofl = a * 'R' + b * 'P' + c * 'S'
		for i in range(len(snew)):
			if snew[i] == '0':
				snew = snew[0:i] + rofl[0] + snew[i + 1:]
				rofl = rofl[1:]
		print('YES')
		print(snew)


import math
t = int(input())
for _ in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = list(input())
	ans = ''
	count = 0
	for i in s:
		if i == 'R':
			if b >= 1:
				b -= 1
				ans += 'P'
				count += 1
			else:
				ans += '-'
		elif i == 'P':
			if c >= 1:
				c -= 1
				ans += 'S'
				count += 1
			else:
				ans += '-'
		elif i == 'S':
			if a >= 1:
				a -= 1
				ans += 'R'
				count += 1
			else:
				ans += '-'
	ans = ans.replace('-', 'R', a)
	ans = ans.replace('-', 'P', b)
	ans = ans.replace('-', 'S', c)
	if count >= math.ceil(n / 2):
		print('YES')
		print(ans)
	else:
		print('NO')


t = int(input())
d = {'R': 'P', 'S': 'R', 'P': 'S'}
for _ in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	beat = {'R': b, 'P': c, 'S': a}
	ans = []
	win = 0
	for i in input():
		if beat[i] > 0:
			win += 1
			beat[i] -= 1
			ans.append(d[i])
		else:
			ans.append(' ')
	for i in range(n):
		if ans[i] == ' ':
			for key in 'RPS':
				if beat[key] != 0:
					ans[i] = d[key]
					beat[key] -= 1
					break
	print('YES\n' + ''.join(ans) if win >= (n + 1) // 2 else 'NO')


t1 = int(input())
from math import ceil
for i in range(t1):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	k = []
	t = 0
	k1 = [' ' for i in range(n)]
	for j in range(len(s)):
		k.append(s[j])
	for j in range(n):
		if s[j] == 'R' and b:
			k1[j] = 'P'
			b = b - 1
			t = t + 1
		if s[j] == 'P' and c:
			k1[j] = 'S'
			c = c - 1
			t = t + 1
		if s[j] == 'S' and a:
			k1[j] = 'R'
			a = a - 1
			t = t + 1
	if t < ceil(n / 2):
		print('NO')
		continue
	print('YES')
	for j in range(n):
		if k1[j] == ' ' and a:
			k1[j] = 'R'
			a = a - 1
		elif k1[j] == ' ' and b:
			k1[j] = 'P'
			b = b - 1
		elif k1[j] == ' ' and c:
			k1[j] = 'S'
			c = c - 1
	print(''.join(k1))


beats = {'R': 'S', 'S': 'P', 'P': 'R'}
t = int(input())
for __ in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	counts = {'R': 0, 'S': 0, 'P': 0}
	for e in s:
		counts[e] += 1
	wins = 0
	wins += min(counts['R'], b)
	wins += min(counts['P'], c)
	wins += min(counts['S'], a)
	l = [0] * len(s)
	ii = 0
	for e in s:
		if e == 'R' and b > 0:
			b -= 1
			l[ii] = 'P'
		elif e == 'P' and c > 0:
			c -= 1
			l[ii] = 'S'
		elif e == 'S' and a > 0:
			a -= 1
			l[ii] = 'R'
		ii += 1
	for i in range(len(l)):
		if l[i] == 0:
			if a > 0:
				l[i] = 'R'
				a -= 1
			elif b > 0:
				l[i] = 'P'
				b -= 1
			elif c > 0:
				l[i] = 'S'
				c -= 1
	if wins >= (n + 1) // 2:
		print('YES')
		for e in l:
			print(e, end='')
		print('')
	else:
		print('NO')


from math import ceil
t = int(input())
for i in range(0, t):
	n = int(input())
	win = 0
	(a, b, c) = map(int, input().split())
	bob = input()
	ans = ['-1'] * n
	for i in range(0, n):
		if bob[i] == 'R':
			if b > 0:
				ans[i] = 'P'
				win += 1
				b -= 1
		elif bob[i] == 'P':
			if c > 0:
				ans[i] = 'S'
				win += 1
				c -= 1
		elif bob[i] == 'S':
			if a > 0:
				ans[i] = 'R'
				win += 1
				a -= 1
	for i in range(0, n):
		if ans[i] == '-1':
			if a > 0:
				ans[i] = 'R'
				a -= 1
			elif b > 0:
				ans[i] = 'P'
				b -= 1
			elif c > 0:
				ans[i] = 'S'
				c -= 1
	if win >= ceil(n / 2):
		print('YES')
		print(''.join(ans))
	else:
		print('NO')


import math
for _ in ' ' * int(input()):
	n = int(input())
	(r, p, sc) = map(int, input().split())
	s = input()
	cnt = 0
	lst = ['0'] * n
	for i in range(n):
		if s[i] == 'R':
			if p:
				p -= 1
				cnt += 1
				lst[i] = 'P'
		elif s[i] == 'P':
			if sc:
				sc -= 1
				cnt += 1
				lst[i] = 'S'
		elif r:
			r -= 1
			cnt += 1
			lst[i] = 'R'
	if cnt >= math.ceil(n / 2):
		print('YES')
		for i in range(n):
			if lst[i] == '0':
				if r:
					r -= 1
					print('R', end='')
				elif sc:
					sc -= 1
					print('S', end='')
				else:
					p -= 1
					print('P', end='')
			else:
				print(lst[i], end='')
		print()
	else:
		print('NO')


import math
for _ in range(int(input())):
	n = int(input())
	w = 0
	b_w = 0
	(a_r, a_p, a_s) = map(int, input().split())
	bob = input()
	s = []
	for i in range(n):
		if bob[i] == 'R':
			if a_p > 0:
				w += 1
				s.append('P')
				a_p -= 1
			else:
				s.append('')
		if bob[i] == 'S':
			if a_r > 0:
				w += 1
				a_r -= 1
				s.append('R')
			else:
				s.append('')
		if bob[i] == 'P':
			if a_s > 0:
				w += 1
				s.append('S')
				a_s -= 1
			else:
				s.append('')
	for i in range(n):
		if s[i] == '':
			if a_r > 0:
				s[i] = 'R'
				a_r -= 1
			elif a_s > 0:
				s[i] = 'S'
				a_s -= 1
			else:
				s[i] = 'P'
				a_p -= 1
	if w >= math.ceil(n / 2):
		print('YES')
		print(''.join(s))
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	(a, b, c) = list(map(int, input().strip().split()))
	bob = input().strip()
	alice = ['z'] * n
	lose = 0
	for i in range(len(bob)):
		if bob[i] == 'R':
			if b:
				b -= 1
				alice[i] = 'P'
			else:
				lose += 1
		elif bob[i] == 'P':
			if c:
				c -= 1
				alice[i] = 'S'
			else:
				lose += 1
		elif bob[i] == 'S':
			if a:
				a -= 1
				alice[i] = 'R'
			else:
				lose += 1
	if n % 2 == 1:
		check = n // 2 + 1
	else:
		check = n // 2
	if n - lose >= check:
		for i in range(n):
			if alice[i] == 'z':
				if a:
					a -= 1
					alice[i] = 'R'
				elif b:
					b -= 1
					alice[i] = 'P'
				elif c:
					c -= 1
					alice[i] = 'S'
		print('YES')
		print(''.join(alice))
	else:
		print('NO')


test = int(input())
for i in range(test):
	n = int(input())
	(a, b, c) = map(int, input().split())
	arr = list(input())
	rock = 0
	paper = 0
	scissors = 0
	for i in range(n):
		if arr[i] == 'R':
			rock += 1
		if arr[i] == 'P':
			paper += 1
		if arr[i] == 'S':
			scissors += 1
	x = min(a, scissors)
	y = min(b, rock)
	z = min(c, paper)
	a = a - x
	b = b - y
	c = c - z
	w = x + y + z
	if 2 * w < n:
		print('NO')
	else:
		print('YES')
		strr = ''
		for i in range(n):
			if arr[i] == 'R' and y > 0:
				strr = strr + 'P'
				y -= 1
			elif arr[i] == 'P' and z > 0:
				strr = strr + 'S'
				z -= 1
			elif arr[i] == 'S' and x > 0:
				strr = strr + 'R'
				x -= 1
			else:
				strr = strr + str('_')
		for i in range(n):
			if strr[i] == '_':
				if a > 0:
					a -= 1
					print('R', end='')
				elif b > 0:
					b -= 1
					print('P', end='')
				elif c > 0:
					c -= 1
					print('S', end='')
			else:
				print(strr[i], end='')
	print()


import sys
import queue

def readFile():
	data = []
	with open('../input.txt') as file:
		for line in file.readlines():
			data.append(line.strip('\n'))
	return data

def readStdin():
	data = []
	for line in sys.stdin.readlines():
		data.append(line.strip('\n'))
	return data

def nod(a, b):
	if a % b == 0:
		return b
	if b % a == 0:
		return a
	return nod(a % b, b) if a > b else nod(a, b % a)
data = readStdin()
n = int(data[0])
for i in range(n):
	t = int(data[1 + i * 3])
	aliceSeq = data[2 + i * 3].split(' ')
	bobSeq = data[3 + i * 3]
	rs = 0
	ps = 0
	ss = 0
	for j in bobSeq:
		if j == 'R':
			rs += 1
		if j == 'P':
			ps += 1
		if j == 'S':
			ss += 1
	wins = min(int(aliceSeq[0]), ss) + min(int(aliceSeq[1]), rs) + min(int(aliceSeq[2]), ps)
	if wins < t / 2:
		print('NO')
	else:
		print('YES')
		dm = queue.Queue()
		for j in range(int(aliceSeq[0]) - ss):
			dm.put('R')
		for j in range(int(aliceSeq[1]) - rs):
			dm.put('P')
		for j in range(int(aliceSeq[2]) - ps):
			dm.put('S')
		aliceTurn = ''
		for j in bobSeq:
			if j == 'S':
				if int(aliceSeq[0]) > 0:
					aliceTurn += 'R'
					aliceSeq[0] = int(aliceSeq[0]) - 1
				else:
					aliceTurn += dm.get()
			if j == 'R':
				if int(aliceSeq[1]) > 0:
					aliceTurn += 'P'
					aliceSeq[1] = int(aliceSeq[1]) - 1
				else:
					aliceTurn += dm.get()
			if j == 'P':
				if int(aliceSeq[2]) > 0:
					aliceTurn += 'S'
					aliceSeq[2] = int(aliceSeq[2]) - 1
				else:
					aliceTurn += dm.get()
		print(aliceTurn)


import math
for t in range(int(input())):
	n = int(input())
	(r, p, s) = map(int, input().split())
	x = input()
	ct = 0
	ans = []
	for i in range(n):
		if x[i] == 'R':
			if p > 0:
				ans.append('P')
				p -= 1
				ct += 1
			else:
				ans.append(0)
		elif x[i] == 'P':
			if s > 0:
				ans.append('S')
				ct += 1
				s -= 1
			else:
				ans.append(0)
		elif r > 0:
			ct += 1
			ans.append('R')
			r -= 1
		else:
			ans.append(0)
	for i in range(n):
		if ans[i] == 0:
			if r > 0:
				ans[i] = 'R'
				r -= 1
			elif p > 0:
				ans[i] = 'P'
				p -= 1
			else:
				ans[i] = 'S'
				s -= 1
	if ct >= (n + 1) // 2:
		print('YES')
		for i in range(n):
			print(ans[i], end='')
		print()
	else:
		print('NO')


t = int(input())
for i in range(t):
	N = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	ans = [0] * N
	for i in range(N):
		if s[i] == 'R' and b > 0:
			ans[i] = 2
			b -= 1
		elif s[i] == 'P' and c > 0:
			ans[i] = 3
			c -= 1
		elif s[i] == 'S' and a > 0:
			ans[i] = 1
			a -= 1
	cnt = 0
	for i in range(N):
		if ans[i] > 0:
			cnt += 1
	for i in range(N):
		if ans[i] == 0:
			if a > 0:
				ans[i] = 1
				a -= 1
			elif b > 0:
				ans[i] = 2
				b -= 1
			elif c > 0:
				ans[i] = 3
				c -= 1
	res = ''
	for i in range(N):
		if ans[i] == 1:
			res += 'R'
		elif ans[i] == 2:
			res += 'P'
		else:
			res += 'S'
	l = N // 2 if N % 2 == 0 else N // 2 + 1
	if cnt >= l:
		print('YES')
		print(res)
	else:
		print('NO')


import math
t = int(input())
for h in range(t):
	n = int(input())
	(a, b, c) = [int(i) for i in input().split()]
	w = input()
	s = []
	for i in range(n):
		el = w[i]
		if el == 'R' and b > 0:
			s.append('P')
			b -= 1
		elif el == 'S' and a > 0:
			s.append('R')
			a -= 1
		elif el == 'P' and c > 0:
			s.append('S')
			c -= 1
		else:
			s.append(0)
	x = s.count(0)
	if x > n - math.ceil(n / 2):
		print('NO')
	else:
		print('YES')
		for el in s:
			if el != 0:
				print(el, end='')
			elif el == 0:
				if a > 0:
					a -= 1
					print('R', end='')
				elif b > 0:
					b -= 1
					print('P', end='')
				else:
					print('S', end='')
		print()


import math

def solve(n, a, b, c, bob_combo):
	my_combo = [''] * n
	score = 0
	i = 0
	while i < n and (a > 0 or b > 0 or c > 0):
		if bob_combo[i] == 'R' and b > 0:
			b -= 1
			my_combo[i] = 'P'
			score += 1
		elif bob_combo[i] == 'P' and c > 0:
			c -= 1
			my_combo[i] = 'S'
			score += 1
		elif bob_combo[i] == 'S' and a > 0:
			a -= 1
			my_combo[i] = 'R'
			score += 1
		i += 1
	if math.ceil(n / 2) > score:
		print('NO')
	else:
		for i in range(len(my_combo)):
			if my_combo[i] == '':
				if a > 0:
					my_combo[i] = 'R'
					a -= 1
				elif b > 0:
					my_combo[i] = 'P'
					b -= 1
				elif c > 0:
					my_combo[i] = 'S'
					c -= 1
		print('YES')
		print(''.join(my_combo))
t = int(input())
for _ in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	bob_combo = input()
	solve(n, a, b, c, bob_combo)


from math import ceil
for _ in range(int(input())):
	n = int(input())
	(r, p, s) = map(int, input().split())
	bob = input()
	alice = [None] * n
	wins = 0
	for i in range(n):
		if bob[i] == 'R':
			if p > 0:
				p -= 1
				alice[i] = 'P'
				wins += 1
		elif bob[i] == 'P':
			if s > 0:
				s -= 1
				alice[i] = 'S'
				wins += 1
		elif r > 0:
			r -= 1
			alice[i] = 'R'
			wins += 1
	for i in range(n):
		if alice[i] == None:
			if r > 0:
				alice[i] = 'R'
				r -= 1
			elif p > 0:
				alice[i] = 'P'
				p -= 1
			else:
				alice[i] = 'S'
				s -= 1
	if wins >= int(ceil(n / 2)):
		print('YES')
		print(''.join(alice))
	else:
		print('NO')


from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
mod = 10 ** 9 + 7
eps = 10 ** (-7)

def inp():
	return int(sys.stdin.readline())

def inpl():
	return list(map(int, sys.stdin.readline().split()))

def inpl_str():
	return list(sys.stdin.readline().split())
t = inp()
for _ in range(t):
	n = inp()
	aa = inpl()
	bb = input()
	ans = []
	for b in bb:
		if b == 'R':
			if aa[1] > 0:
				ans.append('P')
				aa[1] -= 1
			else:
				ans.append(-1)
		elif b == 'P':
			if aa[2] > 0:
				aa[2] -= 1
				ans.append('S')
			else:
				ans.append(-1)
		elif b == 'S':
			if aa[0] > 0:
				aa[0] -= 1
				ans.append('R')
			else:
				ans.append(-1)
	if n - sum(aa) < (n + 1) // 2:
		print('NO')
	else:
		print('YES')
		for i in range(n):
			if ans[i] == -1:
				if aa[0] > 0:
					ans[i] = 'R'
					aa[0] -= 1
				elif aa[1] > 0:
					ans[i] = 'P'
					aa[1] -= 1
				elif aa[2] > 0:
					ans[i] = 'S'
					aa[2] -= 1
		print(''.join(ans))


T = int(input())
for _ in range(T):
	N = int(input())
	(R, P, S) = map(int, input().split())
	Se = input()
	Ans = [-1] * N
	for (i, c) in enumerate(Se):
		if c == 'R':
			if P > 0:
				P -= 1
				Ans[i] = 'P'
		elif c == 'P':
			if S > 0:
				S -= 1
				Ans[i] = 'S'
		elif R > 0:
			R -= 1
			Ans[i] = 'R'
	win_cnt = N - R - P - S
	if win_cnt >= (N + 1) // 2:
		print('YES')
		for i in range(N):
			if Ans[i] == -1:
				if R > 0:
					Ans[i] = 'R'
					R -= 1
				elif P > 0:
					Ans[i] = 'P'
					P -= 1
				else:
					Ans[i] = 'S'
					S -= 1
		assert R == P == S == 0
		print(''.join(Ans))
	else:
		print('NO')


from collections import deque
for _ in range(int(input())):
	n = int(input())
	(r, p, s) = map(int, input().split())
	t = input()
	ans = ['' for i in range(n)]
	w = 0
	for i in range(n):
		if t[i] == 'R':
			if p > 0:
				ans[i] = 'P'
				p -= 1
				w += 1
		elif t[i] == 'P':
			if s > 0:
				ans[i] = 'S'
				s -= 1
				w += 1
		elif r > 0:
			ans[i] = 'R'
			r -= 1
			w += 1
	if w < -(-n // 2):
		print('NO')
	else:
		ansp = deque()
		for i in range(r):
			ansp.append('R')
		for i in range(p):
			ansp.append('P')
		for i in range(s):
			ansp.append('S')
		for i in range(n):
			if ans[i] == '':
				ans[i] = ansp.popleft()
		print('YES')
		print(''.join(ans))


import sys
import itertools
import math
import collections
from collections import Counter

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 1
	prime[0] = prime[1] = False
	r = [p for p in range(n + 1) if prime[p]]
	return r

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)
t = ii()
d = {'R': 'P', 'P': 'S', 'S': 'R'}
for _ in range(t):
	n = ii()
	alice = {}
	(a, b, c) = mi()
	alice['R'] = a
	alice['P'] = b
	alice['S'] = c
	s = input()
	bob = Counter(s)
	t = 0
	for i in 'RPS':
		t += min(bob[i], alice[d[i]])
	if t < ceil(n, 2):
		print('NO')
	else:
		res = [0] * n
		for i in range(n):
			if alice[d[s[i]]] > 0:
				res[i] = d[s[i]]
				alice[d[s[i]]] -= 1
		for i in range(n):
			if res[i] == 0:
				for j in 'RPS':
					if alice[j] > 0:
						res[i] = j
						alice[j] -= 1
						break
		print('YES')
		prr(res, '')


import array
from fractions import Fraction
import functools
import itertools
import math
import os
import sys

def main():
	T = read_int()
	for _ in range(T):
		N = read_int()
		(A, B, C) = read_ints()
		S = inp()
		ans = solve(N, A, B, C, S)
		if not ans:
			print('NO')
		else:
			print('YES')
			print(ans)

def solve(N, A, B, C, S):
	sol = [None] * N
	wins = 0
	for i in range(N):
		if S[i] == 'S' and A > 0:
			sol[i] = 'R'
			A -= 1
			wins += 1
		if S[i] == 'R' and B > 0:
			sol[i] = 'P'
			B -= 1
			wins += 1
		if S[i] == 'P' and C > 0:
			sol[i] = 'S'
			C -= 1
			wins += 1
	if wins < (N + 1) // 2:
		return None
	for i in range(N):
		if sol[i] is None:
			if A > 0:
				sol[i] = 'R'
				A -= 1
			elif B > 0:
				sol[i] = 'P'
				B -= 1
			else:
				sol[i] = 'S'
				C -= 1
	return ''.join(sol)
DEBUG = 'DEBUG' in os.environ

def inp():
	return sys.stdin.readline().rstrip()

def read_int():
	return int(inp())

def read_ints():
	return [int(e) for e in inp().split()]

def dprint(*value, sep=' ', end='\n'):
	if DEBUG:
		print(*value, sep=sep, end=end)
main()


import math
t = int(input())
for i in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = str(input())
	a1 = 0
	b1 = 0
	c1 = 0
	for j in range(n):
		if s[j] == 'R':
			b1 += 1
		elif s[j] == 'P':
			c1 += 1
		else:
			a1 += 1
	ans = min(a, a1) + min(b, b1) + min(c, c1)
	if ans >= math.ceil(n / 2):
		print('YES')
		ss = ''
		aa = min(a, a1)
		bb = min(b, b1)
		cc = min(c, c1)
		afree = a - min(a, a1)
		bfree = b - min(b, b1)
		cfree = c - min(c, c1)
		for j in range(n):
			if s[j] == 'R':
				if bb > 0:
					ss += 'P'
					bb -= 1
				elif afree > 0:
					ss += 'R'
					afree -= 1
				elif cfree > 0:
					ss += 'S'
					cfree -= 1
				elif bfree > 0:
					ss += 'P'
					cfree -= 1
			elif s[j] == 'P':
				if cc > 0:
					ss += 'S'
					cc -= 1
				elif afree > 0:
					ss += 'R'
					afree -= 1
				elif bfree > 0:
					ss += 'P'
					cfree -= 1
				elif cfree > 0:
					ss += 'S'
					cfree -= 1
			elif aa > 0:
				ss += 'R'
				aa -= 1
			elif bfree > 0:
				ss += 'P'
				bfree -= 1
			elif cfree > 0:
				ss += 'S'
				cfree -= 1
			elif afree > 0:
				ss += 'R'
				afree -= 1
		print(ss)
	else:
		print('NO')


import math
t = int(input())
for i in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	(a1, b1, c1) = (0, 0, 0)
	s = input()
	ans = ''
	for j in s:
		if j == 'R':
			a1 += 1
			ans += 'P'
		elif j == 'P':
			b1 += 1
			ans += 'S'
		elif j == 'S':
			c1 += 1
			ans += 'R'
	if a1 <= b and b1 <= c and (c1 <= a):
		print('YES')
		print(ans)
	else:
		count = 0
		ans = ''
		for j in s:
			if j == 'R':
				a1 -= 1
				if b > 0:
					b -= 1
					ans += 'P'
					count += 1
				elif a > c1:
					a -= 1
					ans += 'R'
				elif c > b1:
					c -= 1
					ans += 'S'
			elif j == 'P':
				b1 -= 1
				if c > 0:
					c -= 1
					ans += 'S'
					count += 1
				elif a > c1:
					a -= 1
					ans += 'R'
				elif b > a1:
					b -= 1
					ans += 'P'
			elif j == 'S':
				c1 -= 1
				if a > 0:
					a -= 1
					ans += 'R'
					count += 1
				elif b > a1:
					b -= 1
					ans += 'P'
				elif c > b1:
					c -= 1
					ans += 'S'
		if count >= math.ceil(n / 2):
			print('YES')
			print(ans)
		else:
			print('NO')


t = int(input())
while t:
	n = int(input())
	(a, b, c) = map(int, input().split(' '))
	seq = input()
	n_ans = 0
	ans = ['Q'] * n
	for (i, item) in enumerate(seq):
		if item == 'R' and b > 0:
			ans[i] = 'P'
			b -= 1
			n_ans += 1
		elif item == 'P' and c > 0:
			ans[i] = 'S'
			c -= 1
			n_ans += 1
		elif item == 'S' and a > 0:
			ans[i] = 'R'
			a -= 1
			n_ans += 1
	for (i, item) in enumerate(seq):
		if ans[i] == 'Q':
			if a > 0:
				ans[i] = 'R'
				a -= 1
			elif b > 0:
				ans[i] = 'P'
				b -= 1
			elif c > 0:
				ans[i] = 'S'
				c -= 1
	if n_ans * 2 >= n:
		print('YES')
		print(''.join(ans))
	else:
		print('NO')
	t -= 1


import math
q = int(input())
for i in range(q):
	n = int(input())
	(a, b, c) = map(int, input().split())
	l = input()
	r = l.count('R')
	p = l.count('P')
	s = l.count('S')
	nr = min(a, s) + min(r, b) + min(p, c)
	if nr >= math.ceil(n / 2):
		print('YES')
		st = list()
		for j in range(n):
			if l[j] == 'R' and b > 0:
				st.append('P')
				b -= 1
				continue
			elif l[j] == 'P' and c > 0:
				st.append('S')
				c -= 1
				continue
			elif l[j] == 'S' and a > 0:
				st.append('R')
				a -= 1
				continue
			else:
				st.append(' ')
		for j in range(st.count(' ')):
			index = st.index(' ')
			if a > 0:
				st[index] = 'R'
				a -= 1
			elif b > 0:
				st[index] = 'P'
				b -= 1
			elif c > 0:
				st[index] = 'S'
				c -= 1
		print(*st, sep='')
	else:
		print('NO')


def solve(n, r_count, p_count, s_count, bob):
	p = sum(map(lambda c: int(c == 'P'), bob))
	s = sum(map(lambda c: int(c == 'S'), bob))
	r = sum(map(lambda c: int(c == 'R'), bob))
	pr = min(p_count, r)
	sp = min(s_count, p)
	rs = min(r_count, s)
	if pr + sp + rs < (n + 1) // 2:
		print('NO')
		return
	print('YES')
	free = ['P'] * (p_count - pr) + ['S'] * (s_count - sp) + ['R'] * (r_count - rs)
	free_pos = 0
	ans = [''] * n
	dst = 0
	for x in bob:
		if x == 'R':
			if p_count > 0:
				ans[dst] = 'P'
				p_count -= 1
			else:
				ans[dst] = free[free_pos]
				free_pos += 1
		elif x == 'P':
			if s_count > 0:
				ans[dst] = 'S'
				s_count -= 1
			else:
				ans[dst] = free[free_pos]
				free_pos += 1
		elif r_count > 0:
			ans[dst] = 'R'
			r_count -= 1
		else:
			ans[dst] = free[free_pos]
			free_pos += 1
		dst += 1
	print(''.join(ans))

def main():
	t = int(input())
	inputs = [[]] * t
	for i in range(t):
		n = int(input())
		(r_count, p_count, s_count) = map(int, input().split())
		bob = input()
		inputs[i] = [n, r_count, p_count, s_count, bob]
	for (n, r_count, p_count, s_count, bob) in inputs:
		solve(n, r_count, p_count, s_count, bob)
main()


t = int(input())
for i in range(t):
	n = int(input())
	(rocks, papers, scissors) = (0, 0, 0)
	(a, b, c) = map(int, input().split(' '))
	s = input()
	for i in s:
		if i == 'R':
			rocks += 1
		elif i == 'P':
			papers += 1
		else:
			scissors += 1
	remaining_rocks = a - min(scissors, a)
	remaining_papers = b - min(rocks, b)
	remaining_scissors = c - min(papers, c)
	required = min(a, scissors) + min(b, rocks) + min(c, papers)
	temp = (n + 1) // 2
	if required >= temp:
		print('YES')
		result = []
		for i in s:
			if i == 'R':
				if b > 0:
					result.append('P')
					b -= 1
				elif remaining_rocks > 0:
					result.append('R')
					remaining_rocks -= 1
				elif remaining_papers > 0:
					result.append('P')
					remaining_papers -= 1
				else:
					result.append('S')
					remaining_scissors -= 1
			elif i == 'P':
				if c > 0:
					result.append('S')
					c -= 1
				elif remaining_rocks > 0:
					result.append('R')
					remaining_rocks -= 1
				elif remaining_papers > 0:
					result.append('P')
					remaining_papers -= 1
				else:
					result.append('S')
					remaining_scissors -= 1
			elif a > 0:
				result.append('R')
				a -= 1
			elif remaining_rocks > 0:
				result.append('R')
				remaining_rocks -= 1
			elif remaining_papers > 0:
				result.append('P')
				remaining_papers -= 1
			else:
				result.append('S')
				remaining_scissors -= 1
		for i in result:
			print(i, end='')
		print()
	else:
		print('NO')


import math
d1 = {'R': 'P', 'S': 'R', 'P': 'S'}
d2 = {'R': 0, 'P': 1, 'S': 2}
for _ in range(int(input())):
	n = int(input())
	a = [0, 0, 0]
	(a[0], a[1], a[2]) = map(int, input().split())
	s = input()
	s1 = ''
	for i in s:
		a[d2[d1[i]]] -= 1
		if a[d2[d1[i]]] >= 0:
			s1 += d1[i]
		else:
			s1 += 'Z'
	s2 = ''
	for j in s1:
		if j == 'Z':
			for i in range(len(a)):
				if a[i] > 0:
					a[i] -= 1
					if i == 0:
						s2 += 'R'
						break
					elif i == 1:
						s2 += 'P'
						break
					else:
						s2 += 'S'
						break
		else:
			s2 += j
	sumo = n + sum(a)
	if sumo >= math.ceil(n / 2):
		print('YES')
		print(s2)
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	x = y = z = 0
	for i in range(len(s)):
		if s[i] == 'R':
			x += 1
		elif s[i] == 'P':
			y += 1
		else:
			z += 1
	L = []
	if a >= z:
		p1 = z
		for i in range(a - z):
			L.append('R')
	else:
		p1 = a
	if b >= x:
		p2 = x
		for i in range(b - x):
			L.append('P')
	else:
		p2 = b
	if c >= y:
		p3 = y
		for i in range(c - y):
			L.append('S')
	else:
		p3 = c
	win = p1 + p2 + p3
	if n // 2 == n / 2:
		crit = n // 2
	else:
		crit = n // 2 + 1
	j = 0
	if win >= crit:
		string = ''
		for i in range(len(s)):
			if s[i] == 'R':
				if p2 > 0:
					string += 'P'
					p2 -= 1
				else:
					string += L[j]
					j += 1
			elif s[i] == 'P':
				if p3 > 0:
					string += 'S'
					p3 -= 1
				else:
					string += L[j]
					j += 1
			elif p1 > 0:
				string += 'R'
				p1 -= 1
			else:
				string += L[j]
				j += 1
		print('YES')
		print(string)
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	wd = {'R': 'P', 'P': 'S', 'S': 'R'}
	(a, b, c) = map(int, input().split())
	s = input()
	num = 0
	ans = ['-'] * len(s)
	for i in range(len(s)):
		if s[i] == 'R' and b > 0:
			ans[i] = 'P'
			b -= 1
			num += 1
		if s[i] == 'P' and c > 0:
			ans[i] = 'S'
			c -= 1
			num += 1
		if s[i] == 'S' and a > 0:
			ans[i] = 'R'
			a -= 1
			num += 1
	if num >= (n + 1) // 2:
		print('YES')
		for i in range(len(s)):
			if ans[i] != '-':
				continue
			if a > 0:
				ans[i] = 'R'
				a -= 1
			elif b > 0:
				ans[i] = 'P'
				b -= 1
			elif c > 0:
				ans[i] = 'S'
				c -= 1
		print(''.join(ans))
	else:
		print('NO')


from sys import stdout, stdin, exit
for i in stdin:
	t = int(i)
	break
while t:
	for i in stdin:
		n = int(i)
		break
	for i in stdin:
		(a, b, c) = list(map(int, i.strip().split()))
		break
	for i in stdin:
		s = i.strip()
		break
	x = ''
	for i in s:
		if i == 'R' and b:
			x += 'P'
			b -= 1
		elif i == 'P' and c:
			x += 'S'
			c -= 1
		elif i == 'S' and a:
			x += 'R'
			a -= 1
		else:
			x += 'X'
	if x.count('X') > n // 2:
		stdout.write('NO\n')
	else:
		ss = ''
		for i in x:
			if i == 'X':
				if a > 0:
					ss += 'R'
					a -= 1
				elif b > 0:
					ss += 'P'
					b -= 1
				else:
					ss += 'S'
					c -= 1
			else:
				ss += i
		stdout.write('YES\n')
		stdout.write(ss + '\n')
	t -= 1


nb_cases = int(input())
for case in range(nb_cases):
	n = int(input())
	(alice_r, alice_p, alice_s) = [int(x) for x in input().split()]
	bob_rps = []
	mot = input()
	bob_r = mot.count('R')
	bob_p = mot.count('P')
	bob_s = mot.count('S')
	for x in range(len(mot)):
		bob_rps.append(mot[x])
	alice_rps = [' '] * n
	if min(bob_r, alice_p) + min(bob_p, alice_s) + min(bob_s, alice_r) >= int((n + 1) / 2):
		min_p = min(bob_r, alice_p)
		alice_p -= min_p
		for x in range(n):
			if min_p == 0:
				break
			if bob_rps[x] == 'R':
				alice_rps[x] = 'P'
				min_p -= 1
		min_s = min(bob_p, alice_s)
		alice_s -= min_s
		for x in range(n):
			if min_s == 0:
				break
			if bob_rps[x] == 'P':
				alice_rps[x] = 'S'
				min_s -= 1
		min_r = min(bob_s, alice_r)
		alice_r -= min_r
		for x in range(n):
			if min_r == 0:
				break
			if bob_rps[x] == 'S':
				alice_rps[x] = 'R'
				min_r -= 1
		for x in range(n):
			if alice_rps[x] == ' ':
				if alice_r > 0:
					alice_rps[x] = 'R'
					alice_r -= 1
					continue
				if alice_p > 0:
					alice_rps[x] = 'P'
					alice_p -= 1
					continue
				if alice_s > 0:
					alice_rps[x] = 'S'
					alice_s -= 1
					continue
		print('YES')
		print(''.join(alice_rps))
	else:
		print('NO')


q = int(input())
for i in range(q):
	w = int(input())
	(r1, p1, s1) = map(int, input().split())
	e = input()
	f = ['*'] * w
	for k in range(w):
		if e[k] == 'R' and p1 > 0:
			p1 = p1 - 1
			f[k] = 'P'
		if e[k] == 'P' and s1 > 0:
			s1 = s1 - 1
			f[k] = 'S'
		if e[k] == 'S' and r1 > 0:
			r1 = r1 - 1
			f[k] = 'R'
	if r1 + p1 + s1 > w // 2:
		print('NO')
		continue
	else:
		print('YES')
		for i in range(w):
			if f[i] == '*':
				if r1 > 0:
					r1 -= 1
					f[i] = 'R'
				elif p1 > 0:
					p1 -= 1
					f[i] = 'P'
				elif s1 > 0:
					s1 -= 1
					f[i] = 'S'
			print(f[i], end='')
		print('')


for _ in range(int(input())):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	cnt = [0, 0, 0]
	for i in s:
		if i == 'R':
			cnt[0] += 1
		elif i == 'P':
			cnt[1] += 1
		else:
			cnt[2] += 1
	w = min(a, cnt[2]) + min(b, cnt[0]) + min(c, cnt[1])
	if w * 2 < n:
		print('NO')
	else:
		print('YES')
		ans = ''
		for ch in s:
			if ch == 'R' and b:
				ans += 'P'
				b -= 1
			elif ch == 'P' and c:
				ans += 'S'
				c -= 1
			elif ch == 'S' and a:
				ans += 'R'
				a -= 1
			else:
				ans += '_'
		for i in range(n):
			if ans[i] != '_':
				continue
			elif a:
				ans = ans[:i] + 'R' + ans[i + 1:]
				a -= 1
			elif b:
				ans = ans[:i] + 'P' + ans[i + 1:]
				b -= 1
			else:
				ans = ans[:i] + 'S' + ans[i + 1:]
		print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	ans = [''] * n
	(i, j, k) = (s.count('R'), s.count('P'), s.count('S'))
	(x, y, z) = (min(i, b), min(j, c), min(k, a))
	flag = 0
	if 2 * (x + y + z) < n:
		print('no')
	else:
		print('yes')
		tt = 0
		for kl in s:
			if kl == 'R' and b > 0:
				b -= 1
				ans[tt] = 'P'
			elif kl == 'P' and c > 0:
				c -= 1
				ans[tt] = 'S'
			elif kl == 'S' and a > 0:
				a -= 1
				ans[tt] = 'R'
			else:
				ans[tt] = 'o'
			tt += 1
		for kl in range(n):
			if ans[kl] == 'o':
				if a > 0:
					a -= 1
					ans[kl] = 'R'
				elif b > 0:
					b -= 1
					ans[kl] = 'P'
				elif c > 0:
					c -= 1
					ans[kl] = 'S'
		for kl in ans:
			print(kl, end='')
		print('')


import math
for h in range(int(input())):
	n = int(input())
	(R, P, S) = map(int, input().strip().split())
	seq = input()
	r = seq.count('R')
	p = seq.count('P')
	s = seq.count('S')
	reqR = min(R, s)
	reqS = min(S, p)
	reqP = min(P, r)
	tot = reqR + reqS + reqP
	ans = ''
	if tot >= math.ceil(n / 2):
		print('YES')
		for i in seq:
			if i == 'R' and P > 0:
				ans += 'P'
				reqP -= 1
				P -= 1
			elif i == 'P' and S > 0:
				ans += 'S'
				reqS -= 1
				S -= 1
			elif i == 'S' and R > 0:
				ans += 'R'
				reqR -= 1
				R -= 1
			elif R > reqR:
				ans += 'R'
				R -= 1
			elif S > reqS:
				ans += 'S'
				S -= 1
			elif P > reqP:
				ans += 'P'
				P -= 1
		print(ans)
	else:
		print('NO')


t = int(input())
import math
while t > 0:
	n = int(input())
	(r, p, s) = map(int, input().split())
	st = input()
	reach = math.ceil(n / 2)
	count = 0
	output = ''
	for i in st:
		if i == 'R':
			if p > 0:
				p -= 1
				output += 'P'
				count += 1
			else:
				output += 'e'
		elif i == 'P':
			if s > 0:
				s -= 1
				output += 'S'
				count += 1
			else:
				output += 'e'
		elif r > 0:
			r -= 1
			output += 'R'
			count += 1
		else:
			output += 'e'
	newO = ''
	if count >= reach:
		print('YES')
		if r == 0 and p == 0 and (s == 0):
			print(output)
		else:
			for i in output:
				if i == 'e':
					if r > 0:
						newO += 'R'
						r -= 1
					elif p > 0:
						newO += 'P'
						p -= 1
					else:
						newO += 'S'
						s -= 1
				else:
					newO += i
			print(newO)
	else:
		print('NO')
	t -= 1


from math import ceil

def solve(r, p, s, strng):
	to_win = ceil(len(strng) / 2)
	wins = 0
	res = []
	reps = []
	for i in range(len(strng)):
		if strng[i] == 'R' and p > 0:
			res += 'P'
			wins += 1
			p -= 1
		elif strng[i] == 'P' and s > 0:
			res += 'S'
			wins += 1
			s -= 1
		elif strng[i] == 'S' and r > 0:
			res += 'R'
			wins += 1
			r -= 1
		else:
			res += strng[i]
			reps.append(i)
	if wins < to_win:
		print('NO')
	else:
		print('YES')
		for i in reps:
			if r > 0:
				res[i] = 'R'
				r -= 1
			elif p > 0:
				res[i] = 'P'
				p -= 1
			elif s > 0:
				res[i] = 'S'
				s -= 1
		print(''.join(res))
t = int(input())
for _ in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	strng = input()
	solve(a, b, c, strng)


from math import ceil
t = int(input())
for i in range(t):
	n = int(input())
	(a, b, c) = list(map(int, input().split()))
	moves = input()
	num_r = 0
	num_p = 0
	num_s = 0
	for move in moves:
		if move == 'R':
			num_r += 1
		elif move == 'P':
			num_p += 1
		elif move == 'S':
			num_s += 1
	wins = min(a, num_s) + min(b, num_r) + min(c, num_p)
	if wins < ceil(n / 2):
		print('NO')
	else:
		rock_moves = min(b, num_r)
		paper_moves = min(c, num_p)
		scissor_moves = min(a, num_s)
		remaining_rocks = a - min(a, num_s)
		remaining_paper = b - min(b, num_r)
		remaining_scissors = c - min(c, num_p)
		remaining_list = ['R'] * remaining_rocks + ['P'] * remaining_paper + ['S'] * remaining_scissors
		ans = ''
		for move in moves:
			if move == 'R':
				if rock_moves:
					ans += 'P'
					rock_moves -= 1
				else:
					ans += remaining_list[-1]
					del remaining_list[-1]
			elif move == 'P':
				if paper_moves:
					ans += 'S'
					paper_moves -= 1
				else:
					ans += remaining_list[-1]
					del remaining_list[-1]
			elif move == 'S':
				if scissor_moves:
					ans += 'R'
					scissor_moves -= 1
				else:
					ans += remaining_list[-1]
					del remaining_list[-1]
		print('YES')
		print(ans)


t = int(input())
for ups in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	sl = {'R': a, 'P': b, 'S': c}
	used = [0 for i in range(n)]
	ans = ['x'] * n
	cnt = 0
	for i in range(n):
		if s[i] == 'R':
			if sl['P'] > 0:
				sl['P'] -= 1
				cnt += 1
				ans[i] = 'P'
				used[i] = 1
		if s[i] == 'P':
			if sl['S'] > 0:
				sl['S'] -= 1
				cnt += 1
				ans[i] = 'S'
				used[i] = 1
		if s[i] == 'S':
			if sl['R'] > 0:
				sl['R'] -= 1
				cnt += 1
				ans[i] = 'R'
				used[i] = 1
	voz = n // 2
	if n % 2 == 1:
		voz += 1
	if cnt < voz:
		print('NO')
		continue
	print('YES')
	for i in range(n):
		if ans[i] == 'x':
			if sl['S'] > 0:
				sl['S'] -= 1
				ans[i] = 'S'
				continue
			if sl['R'] > 0:
				sl['R'] -= 1
				ans[i] = 'R'
				continue
			if sl['P'] > 0:
				sl['P'] -= 1
				ans[i] = 'P'
				continue
	print(''.join(ans))


t = int(input())
for _ in range(t):
	n = int(input())
	(a, b, c) = map(int, input().rstrip().split(' '))
	S = input()
	r = p = s = 0
	for i in S:
		if i == 'R':
			r += 1
		elif i == 'P':
			p += 1
		elif i == 'S':
			s += 1
	wins = min(r, b) + min(p, c) + min(s, a)
	if wins >= (n + 1) // 2:
		print('YES')
		res = ''
		for i in S:
			if i == 'R':
				if b > 0:
					res += 'P'
					b -= 1
				else:
					res += 'x'
			elif i == 'P':
				if c > 0:
					res += 'S'
					c -= 1
				else:
					res += 'x'
			elif a > 0:
				res += 'R'
				a -= 1
			else:
				res += 'x'
		res = list(res)
		for i in range(len(res)):
			if res[i] == 'x':
				if a:
					res[i] = 'R'
					a -= 1
				elif b:
					res[i] = 'P'
					b -= 1
				elif c:
					res[i] = 'S'
					c -= 1
		print(''.join(res))
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	(r, p, s) = map(int, input().split())
	u = list(input())
	for i in range(n):
		if u[i] == 'R':
			u[i] = 'P'
		elif u[i] == 'P':
			u[i] = 'S'
		else:
			u[i] = 'R'
	a = ['#'] * n
	lose = 0
	for i in range(n):
		if u[i] == 'R' and r > 0:
			a[i] = 'R'
			r -= 1
		elif u[i] == 'P' and p > 0:
			a[i] = 'P'
			p -= 1
		elif u[i] == 'S' and s > 0:
			a[i] = 'S'
			s -= 1
		else:
			lose += 1
	if lose * 2 > n:
		print('NO')
		continue
	print('YES')
	for i in range(n):
		if a[i] == '#':
			if r > 0:
				a[i] = 'R'
				r -= 1
			elif p > 0:
				a[i] = 'P'
				p -= 1
			else:
				a[i] = 'S'
				s -= 1
	print(''.join(a))


import math
t = int(input())
for _ in ' ' * t:
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	rock = 0
	noj = 0
	paper = 0
	for i in s:
		if i == 'S':
			noj += 1
		elif i == 'P':
			paper += 1
		else:
			rock += 1
	h = min(a, noj) + min(b, rock) + min(c, paper)
	if h >= math.ceil(n / 2):
		print('YES')
		ostA = 0 if noj >= a else a - noj
		ostB = 0 if rock >= b else b - rock
		ostC = 0 if paper >= c else c - paper
		for i in s:
			if i == 'S':
				if a > 0:
					a -= 1
					print('R', end='')
				elif ostB > 0:
					print('P', end='')
					ostB -= 1
				else:
					print('S', end='')
					ostC -= 1
			elif i == 'P':
				if c > 0:
					c -= 1
					print('S', end='')
				elif ostB > 0:
					print('P', end='')
					ostB -= 1
				else:
					print('R', end='')
					ostA -= 1
			elif b > 0:
				b -= 1
				print('P', end='')
			elif ostA > 0:
				print('R', end='')
				ostA -= 1
			else:
				print('S', end='')
				ostC -= 1
		print('')
	else:
		print('NO')


for s in range(int(input())):
	ans = ''
	score = 0
	n = int(input())
	(a, b, c) = map(int, input().split())
	bob = list(input())
	for i in bob:
		if i == 'R':
			if b > 0:
				ans += 'P'
				score += 1
				b -= 1
			else:
				ans += '0'
		elif i == 'P':
			if c > 0:
				ans += 'S'
				score += 1
				c -= 1
			else:
				ans += '0'
		elif i == 'S':
			if a > 0:
				ans += 'R'
				score += 1
				a -= 1
			else:
				ans += '0'
	if int(round(n / 2 + 0.1)) > score:
		print('NO')
	else:
		print('YES')
		ans = list(ans)
		for j in ans:
			if j == '0':
				if a > 0:
					ans[ans.index(j)] = 'R'
					a -= 1
				elif b > 0:
					ans[ans.index(j)] = 'P'
					b -= 1
				elif c > 0:
					ans[ans.index(j)] = 'S'
					c -= 1
		print(''.join(ans))


D = {'R': 0, 'P': 1, 'S': 2}
RD = {0: 'R', 1: 'P', 2: 'S'}
testCases = int(input())
for i in range(0, testCases):
	N = int(input())
	have = input().split()
	for j in range(0, len(have)):
		have[j] = int(have[j])
	s = input()
	ans = list()
	aliceScore = 0
	for j in range(0, len(s)):
		idx = (D[s[j]] + 1) % 3
		if have[idx] > 0:
			have[idx] -= 1
			aliceScore += 1
			ans += RD[idx]
		else:
			ans += '?'
	for j in range(0, len(s)):
		if ans[j] in D:
			continue
		idx = D[s[j]]
		next_ = (idx + 1) % 3
		last_ = (idx + 2) % 3
		if have[idx] > 0:
			have[idx] -= 1
			ans[j] = s[j]
		elif have[last_] > 0:
			have[last_] -= 1
			ans[j] = RD[last_]
		else:
			have[next_] -= 1
			ans[j] = RD[next_]
	if aliceScore * 2 < N:
		print('NO')
		continue
	print('YES')
	for j in range(0, len(ans)):
		print(ans[j], end='')
	print('')


import math
tcs = int(input())
for _ in range(tcs):
	n = int(input())
	(rock, paper, sci) = map(int, input().split())
	bob = list(input())
	res = [''] * n
	win = 0
	for i in range(n):
		if bob[i] == 'S' and rock > 0:
			rock -= 1
			res[i] = 'R'
			win += 1
		elif bob[i] == 'P' and sci > 0:
			sci -= 1
			res[i] = 'S'
			win += 1
		elif bob[i] == 'R' and paper > 0:
			paper -= 1
			res[i] = 'P'
			win += 1
	if win >= int(n / 2 + 0.5):
		for i in range(n):
			if res[i] == '' and rock > 0:
				res[i] = 'R'
				rock -= 1
			elif res[i] == '' and sci > 0:
				res[i] = 'S'
				sci -= 1
			elif res[i] == '' and paper > 0:
				res[i] = 'P'
				paper -= 1
		print('YES')
		for i in range(n):
			print(res[i], end='')
		print()
	else:
		print('NO')


t = int(input())
import math
for _ in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = str(input())
	aa = s.count('R')
	bb = s.count('P')
	cc = s.count('S')
	win = min(a, cc) + min(b, aa) + min(c, bb)
	if win >= math.ceil(n / 2):
		print('YES')
		ans = ['' for i in range(n)]
		i = 0
		while i < n and a != 0:
			if s[i] == 'S':
				ans[i] = 'R'
				a -= 1
			i += 1
		i = 0
		while i < n and b != 0:
			if s[i] == 'R':
				ans[i] = 'P'
				b -= 1
			i += 1
		i = 0
		while i < n and c != 0:
			if s[i] == 'P':
				ans[i] = 'S'
				c -= 1
			i += 1
		for i in range(n):
			if ans[i] == '':
				if a != 0:
					ans[i] = 'R'
					a -= 1
				elif b != 0:
					ans[i] = 'P'
					b -= 1
				elif c != 0:
					ans[i] = 'S'
					c -= 1
		print(''.join(ans))
	else:
		print('NO')


from math import ceil

def ass(x, i, v):
	l = list(x)
	l[i] = v
	return ''.join(l)
for i in range(int(input())):
	n = int(input())
	(r, p, s) = map(int, input().split())
	bob = input()
	rock = sum([1 if x == 'R' else 0 for x in bob])
	paper = sum([1 if x == 'P' else 0 for x in bob])
	sci = sum([1 if x == 'S' else 0 for x in bob])
	ans = min(r, sci) + min(p, rock) + min(s, paper)
	if ans >= ceil(n / 2):
		print('YES')
		bob2 = '1' * len(bob)
		for i in range(len(bob)):
			if bob[i] == 'R' and p > 0:
				bob2 = ass(bob2, i, 'P')
				p -= 1
			if bob[i] == 'P' and s > 0:
				bob2 = ass(bob2, i, 'S')
				s -= 1
			if bob[i] == 'S' and r > 0:
				bob2 = ass(bob2, i, 'R')
				r -= 1
		for (i, x) in enumerate(bob2):
			if x == '1':
				if p > 0:
					bob2 = ass(bob2, i, 'P')
					p -= 1
				elif s > 0:
					bob2 = ass(bob2, i, 'S')
					s -= 1
				elif r > 0:
					bob2 = ass(bob2, i, 'R')
					r -= 1
		print(bob2)
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	(r, p, s) = map(int, input().split())
	S = input()
	P = []
	wins = 0
	for c in S:
		if c == 'S':
			if r > 0:
				P.append('R')
				wins += 1
				r -= 1
			else:
				P.append('X')
		elif c == 'P':
			if s > 0:
				P.append('S')
				wins += 1
				s -= 1
			else:
				P.append('X')
		elif p > 0:
			P.append('P')
			wins += 1
			p -= 1
		else:
			P.append('X')
	for i in range(len(P)):
		if P[i] == 'X':
			if r > 0:
				P[i] = 'R'
				r -= 1
			elif s > 0:
				P[i] = 'S'
				s -= 1
			elif p > 0:
				P[i] = 'P'
				p -= 1
	if wins >= n // 2 + n % 2:
		print('YES')
		print(''.join(P))
	else:
		print('NO')


import math
for nt in range(int(input())):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	ans = ''
	for i in s:
		if i == 'R':
			if b > 0:
				b -= 1
				ans += 'P'
			else:
				ans += 'A'
		if i == 'P':
			if c > 0:
				c -= 1
				ans += 'S'
			else:
				ans += 'A'
		if i == 'S':
			if a > 0:
				a -= 1
				ans += 'R'
			else:
				ans += 'A'
	if len(ans) - ans.count('A') >= math.ceil(n / 2):
		print('YES')
		f = ''
		for i in ans:
			if i != 'A':
				f += i
			elif a > 0:
				a -= 1
				f += 'R'
			elif b > 0:
				b -= 1
				f += 'P'
			else:
				c -= 1
				f += 'S'
		print(f)
	else:
		print('NO')


import math
t = int(input())
for i in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	u = input()
	l = []
	for i in u:
		l.append(i)
	x = [0, 0, 0]
	for i in l:
		if i == 'R':
			x[0] += 1
		if i == 'S':
			x[1] += 1
		if i == 'P':
			x[2] += 1
	count = 0
	count += min(x[1], a)
	count += min(x[0], b)
	count += min(x[2], c)
	if count >= math.ceil(n / 2):
		print('YES')
		o = []
		for i in range(n):
			if l[i] == 'R':
				if b > 0:
					o.append('P')
					b -= 1
				else:
					o.append(0)
			if l[i] == 'S':
				if a > 0:
					o.append('R')
					a -= 1
				else:
					o.append(0)
			if l[i] == 'P':
				if c > 0:
					o.append('S')
					c -= 1
				else:
					o.append(0)
		for i in range(n):
			if o[i] == 0:
				if a > 0:
					o[i] = 'R'
					a -= 1
				elif b > 0:
					o[i] = 'P'
					b -= 1
				else:
					o[i] = 'S'
		print(''.join(o))
	else:
		print('NO')


tests = int(input())
for _ in range(tests):
	n = int(input())
	(a, b, c) = map(int, input().split())
	f = input()
	ans = [0] * n
	for i in range(n):
		if f[i] == 'R':
			if b != 0:
				ans[i] = 'P'
				b -= 1
		if f[i] == 'P':
			if c != 0:
				ans[i] = 'S'
				c -= 1
		if f[i] == 'S':
			if a != 0:
				ans[i] = 'R'
				a -= 1
	if ans.count(0) <= n // 2:
		print('YES')
		for i in ans:
			if i == 0:
				if a != 0:
					a -= 1
					print('R', end='')
				elif b != 0:
					b -= 1
					print('P', end='')
				elif c != 0:
					c -= 1
					print('S', end='')
			else:
				print(i, end='')
		print()
	else:
		print('NO')


from math import ceil
t = int(input())
for _ in range(t):
	n = int(input())
	(ra, pa, sa) = map(int, input().split())
	g = input().strip()
	rb = g.count('R')
	pb = g.count('P')
	sb = g.count('S')
	wins = min(rb, pa) + min(pb, sa) + min(sb, ra)
	if wins < ceil(n / 2):
		print('NO')
	else:
		print('YES')
		cnt_r = ra
		cnt_p = pa
		cnt_s = sa
		need_r = min(ra, sb)
		need_p = min(pa, rb)
		need_s = min(sa, pb)
		extra_r = ra - need_r
		extra_p = pa - need_p
		extra_s = sa - need_s
		for c in g:
			if c == 'R' and cnt_p > 0:
				print('P', end='')
				cnt_p -= 1
			elif c == 'P' and cnt_s > 0:
				print('S', end='')
				cnt_s -= 1
			elif c == 'S' and cnt_r > 0:
				print('R', end='')
				cnt_r -= 1
			elif extra_r > 0:
				print('R', end='')
				extra_r -= 1
			elif extra_p > 0:
				print('P', end='')
				extra_p -= 1
			elif extra_s > 0:
				print('S', end='')
				extra_s -= 1
		print()


for _ in range(int(input())):
	a = int(input())
	b = list(map(int, input().split()))
	c = [ele for ele in input()]
	R = b[0]
	P = b[1]
	S = b[2]
	r = c.count('R')
	p = c.count('P')
	s = c.count('S')
	score = 0
	l = ['X'] * a
	pret_score = min(R, s) + min(P, r) + min(S, p)
	if a % 2 == 0:
		t = a // 2
	else:
		t = a // 2 + 1
	if pret_score >= t:
		print('Yes')
		for pq in range(len(c)):
			if c[pq] == 'R':
				if P > 0:
					P = P - 1
					l[pq] = 'P'
					score = score + 1
			elif c[pq] == 'P':
				if S > 0:
					S = S - 1
					l[pq] = 'S'
					score += 1
			elif c[pq] == 'S':
				if R > 0:
					R = R - 1
					l[pq] = 'R'
					score += 1
		for k in range(len(l)):
			if l[k] == 'X':
				if P:
					l[k] = 'P'
					P = P - 1
				elif R:
					l[k] = 'R'
					R = R - 1
				elif S:
					l[k] = 'S'
					S = S - 1
		u = ''
		for num in l:
			u = u + num
		print(u)
	else:
		print('No')


from sys import stdin
inp = lambda : stdin.readline().strip()
t = int(inp())
for _ in range(t):
	n = int(inp())
	(a, b, c) = [int(x) for x in inp().split()]
	st = inp()
	r = 0
	p = 0
	s = 0
	for i in st:
		if i == 'R':
			r += 1
		if i == 'P':
			p += 1
		if i == 'S':
			s += 1
	wins = min(a, s) + min(b, r) + min(c, p)
	if wins >= (n + 1) // 2:
		print('YES')
		ans = [0] * n
		for i in range(n):
			if st[i] == 'R' and b > 0:
				ans[i] = 'P'
				b -= 1
			if st[i] == 'P' and c > 0:
				ans[i] = 'S'
				c -= 1
			if st[i] == 'S' and a > 0:
				ans[i] = 'R'
				a -= 1
		for i in range(n):
			if ans[i] == 0:
				if a > 0:
					ans[i] = 'R'
					a -= 1
				elif b > 0:
					ans[i] = 'P'
					b -= 1
				else:
					ans[i] = 'S'
					c -= 1
		print(''.join(ans))
	else:
		print('NO')


from math import ceil
t = int(input())
for i in range(t):
	n = int(input())
	(r, p, s) = [int(i) for i in input().split()]
	play = input()
	win = [''] * n
	win_skipped = []
	for i in range(n):
		if play[i] == 'R':
			if p > 0:
				win[i] = 'P'
				p -= 1
		elif play[i] == 'P':
			if s > 0:
				win[i] = 'S'
				s -= 1
		elif play[i] == 'S':
			if r > 0:
				win[i] = 'R'
				r -= 1
		if not win[i]:
			win_skipped.append(i)
	loosed = len(win_skipped)
	if n - loosed >= ceil(n / 2):
		print('YES')
		for i in range(loosed):
			if r > 0:
				win[win_skipped[i]] = 'R'
				r -= 1
			elif s > 0:
				win[win_skipped[i]] = 'S'
				s -= 1
			elif p > 0:
				win[win_skipped[i]] = 'P'
				p -= 1
		print(''.join(win))
	else:
		print('NO')


import math
T = int(input())
while T > 0:
	n = int(input())
	(a, b, c) = map(int, input().split())
	seq = input()
	aliceWins = 0
	bobWins = 0
	winCombo = ''
	for ch in seq:
		if ch == 'R':
			if b > 0:
				winCombo += 'P'
				b -= 1
				aliceWins += 1
			else:
				bobWins += 1
				winCombo += 'x'
		elif ch == 'P':
			if c > 0:
				winCombo += 'S'
				c -= 1
				aliceWins += 1
			else:
				bobWins += 1
				winCombo += 'x'
		elif a > 0:
			winCombo += 'R'
			a -= 1
			aliceWins += 1
		else:
			bobWins += 1
			winCombo += 'x'
	winCombo = list(winCombo)
	for i in range(len(winCombo)):
		if winCombo[i] == 'x':
			if a > 0:
				winCombo[i] = 'R'
				a -= 1
			elif b > 0:
				winCombo[i] = 'P'
				b -= 1
			else:
				winCombo[i] = 'S'
				c -= 1
	winCombo = ''.join(winCombo)
	if aliceWins >= math.ceil(n / 2):
		print('YES')
		print(winCombo)
	else:
		print('NO')
	T -= 1


r = lambda : list(map(int, input().split()))
t = int(input())
for _ in range(t):
	n = int(input())
	need = (n + 1) // 2
	(a, b, c) = map(int, input().split())
	s = input()
	ans = ''
	win = 0
	for i in s:
		if i == 'R':
			if b:
				b -= 1
				ans += 'P'
				win += 1
			else:
				ans += '_'
		if i == 'P':
			if c:
				c -= 1
				ans += 'S'
				win += 1
			else:
				ans += '_'
		if i == 'S':
			if a:
				a -= 1
				ans += 'R'
				win += 1
			else:
				ans += '_'
	ans = list(ans)
	for (x, i) in enumerate(ans):
		if i == '_':
			if a:
				ans[x] = 'R'
				a -= 1
			elif b:
				ans[x] = 'P'
				b -= 1
			else:
				ans[x] = 'S'
				c -= 1
	ans = ''.join(ans)
	print(f'YES\n{ans}' if win >= need else 'NO')


import sys
import math

def readline():
	return input()

def fun(n, a, b, c, s):
	ans = ['-'] * n
	w = 0
	for i in range(n):
		if s[i] == 'R':
			if b > 0:
				b = b - 1
				ans[i] = 'P'
				w = w + 1
			else:
				ans[i] = '-'
		if s[i] == 'P':
			if c > 0:
				c = c - 1
				ans[i] = 'S'
				w = w + 1
			else:
				ans[i] = '-'
		if s[i] == 'S':
			if a > 0:
				a = a - 1
				ans[i] = 'R'
				w = w + 1
			else:
				ans[i] = '-'
	for i in range(n):
		if ans[i] == '-':
			if a > 0:
				ans[i] = 'R'
				a = a - 1
			elif b > 0:
				ans[i] = 'P'
				b = b - 1
			elif c > 0:
				ans[i] = 'S'
				c = c - 1
	if w >= math.ceil(n / 2):
		print('YES')
		print(''.join(ans))
	else:
		print('NO')
q = int(readline())
for i in range(q):
	n = int(readline())
	v = list(map(int, readline().split(' ')))
	s = readline()
	ans = fun(n, v[0], v[1], v[2], s)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import math
testcases = int(input())
for j in range(testcases):
	n = int(input())
	(a, b, c) = map(int, input().split())
	(a1, b1, c1) = (a, b, c)
	str1 = input()
	outy = [0] * n
	dict1 = {'R': [], 'P': [], 'S': []}
	wins = 0
	for s in range(n):
		if str1[s] == 'R':
			dict1['R'].append(s)
		elif str1[s] == 'P':
			dict1['P'].append(s)
		else:
			dict1['S'].append(s)
	for s in range(min(b, len(dict1['R']))):
		outy[dict1['R'][s]] = 'P'
		b1 -= 1
		wins += 1
	for s in range(min(c, len(dict1['P']))):
		outy[dict1['P'][s]] = 'S'
		c1 -= 1
		wins += 1
	for s in range(min(a, len(dict1['S']))):
		outy[dict1['S'][s]] = 'R'
		a1 -= 1
		wins += 1
	for s in range(n):
		if outy[s] == 0:
			if a1 != 0:
				outy[s] = 'R'
				a1 -= 1
			elif b1 != 0:
				outy[s] = 'P'
				b1 -= 1
			else:
				outy[s] = 'S'
				c1 -= 1
	if wins >= math.ceil(n / 2):
		print('YES')
		print(''.join(outy))
	else:
		print('NO')


from collections import defaultdict as df
import bisect
from sys import stdin, stdout
import math
t = int(input())
for ii in range(t):
	n = int(input())
	(a, b, c) = list(map(int, input().split()))
	s = input().rstrip()
	r = s.count('R')
	p = s.count('P')
	si = s.count('S')
	ans = min(a, si) + min(b, r) + min(c, p)
	flag = 0
	if ans >= math.ceil(n / 2):
		flag = 1
	if flag == 0:
		print('NO')
	else:
		ans = [0] * len(s)
		for i in range(len(s)):
			if s[i] == 'R':
				if b > 0:
					b -= 1
					ans[i] = 'P'
			elif s[i] == 'P':
				if c > 0:
					c -= 1
					ans[i] = 'S'
			elif s[i] == 'S':
				if a > 0:
					a -= 1
					ans[i] = 'R'
		for i in range(len(ans)):
			if ans[i] == 0:
				if b > 0:
					b -= 1
					ans[i] = 'P'
				elif c > 0:
					c -= 1
					ans[i] = 'S'
				elif a > 0:
					a -= 1
					ans[i] = 'R'
		print('YES')
		print(''.join(ans))


from collections import deque as de
import math
from collections import Counter as cnt
from functools import reduce
from typing import MutableMapping
from itertools import groupby as gb
from fractions import Fraction as fr
from bisect import bisect_left as bl, bisect_right as br

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

class My_stack:

	def __init__(self):
		self.data = []

	def my_push(self, x):
		return self.data.append(x)

	def my_pop(self):
		return self.data.pop()

	def my_peak(self):
		return self.data[-1]

	def my_contains(self, x):
		return self.data.count(x)

	def my_show_all(self):
		return self.data

	def isEmpty(self):
		return len(self.data) == 0
arrStack = My_stack()

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def binarytodecimal(n):
	return int(n, 2)

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def get_prime_factors(number):
	prime_factors = []
	while number % 2 == 0:
		prime_factors.append(2)
		number = number / 2
	for i in range(3, int(math.sqrt(number)) + 1, 2):
		while number % i == 0:
			prime_factors.append(int(i))
			number = number / i
	if number > 2:
		prime_factors.append(int(number))
	return prime_factors

def get_frequency(list):
	dic = {}
	for ele in list:
		if ele in dic:
			dic[ele] += 1
		else:
			dic[ele] = 1
	return dic

def Log2(x):
	return math.log10(x) / math.log10(2)

def isPowerOfTwo(n):
	return math.ceil(Log2(n)) == math.floor(Log2(n))

def ceildiv(x, y):
	return (x + y - 1) // y

def di():
	return map(int, input().split())

def li():
	return list(map(str, input()))
t = int(input())
while t:
	t -= 1
	n = int(input())
	(rr, pp, ss) = di()
	s = li()
	cr = s.count('R')
	cp = s.count('P')
	cs = s.count('S')
	wins = 0
	wins += min(cr, pp)
	rep = min(cr, pp)
	wins += min(cp, ss)
	res = min(cp, ss)
	wins += min(cs, rr)
	rer = min(cs, rr)
	if n % 2:
		n += 1
	if wins >= n // 2:
		print('YES')
		ans = ''
		lp = pp - rep
		lr = rr - rer
		ls = ss - res
		for i in range(len(s)):
			if s[i] == 'R' and rep:
				ans += 'P'
				rep -= 1
			elif s[i] == 'P' and res:
				ans += 'S'
				res -= 1
			elif s[i] == 'S' and rer:
				ans += 'R'
				rer -= 1
			elif lp:
				ans += 'P'
				lp -= 1
			elif lr:
				ans += 'R'
				lr -= 1
			elif ls:
				ans += 'S'
				ls -= 1
		print(ans)
	else:
		print('NO')


num_inputs = int(input())
for _ in range(num_inputs):
	n = int(input())
	(a, b, c) = [int(x) for x in input().split()]
	s = input()
	final_points = [a - s.count('S'), b - s.count('R'), c - s.count('P')]
	wins = 0
	winning_sequence = [None for _ in s]
	for (i, s) in enumerate(s):
		if s == 'R':
			if b > 0:
				winning_sequence[i] = 'P'
				b -= 1
				wins += 1
		elif s == 'P':
			if c > 0:
				winning_sequence[i] = 'S'
				c -= 1
				wins += 1
		elif a > 0:
			winning_sequence[i] = 'R'
			a -= 1
			wins += 1
		if winning_sequence[i] is None:
			if final_points[0] > 0:
				winning_sequence[i] = 'R'
				final_points[0] -= 1
			elif final_points[1] > 0:
				winning_sequence[i] = 'P'
				final_points[1] -= 1
			elif final_points[2] > 0:
				winning_sequence[i] = 'S'
				final_points[2] -= 1
	(q, r) = divmod(n, 2)
	if wins >= q + (r != 0):
		print('YES')
		print(''.join(winning_sequence))
	else:
		print('NO')


t = int(input())
w = {'R': [1, 'P'], 'P': [2, 'S'], 'S': [0, 'R']}
for i in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	s = input()
	wcnt = 0
	ans = []
	for x in s:
		m = w[x][0]
		if p[m] > 0:
			p[m] -= 1
			ans.append(w[x][1])
			wcnt += 1
		else:
			ans.append(-1)
	for j in range(len(ans)):
		if ans[j] == -1:
			for k in range(len(p)):
				if p[k] > 0:
					ans[j] = list(w.keys())[k]
					p[k] -= 1
					break
	if wcnt >= -(-n // 2):
		print('YES')
		print(*ans, sep='')
	else:
		print('NO')


from collections import Counter
t = int(input())
for _ in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	dA = {'R': a, 'P': b, 'S': c}
	s = input()
	dB = Counter(s)
	wP = min(dB['R'], dA['P'])
	wS = min(dB['P'], dA['S'])
	wR = min(dB['S'], dA['R'])
	wins = wR + wP + wS
	if wins < n / 2:
		print('NO')
	else:
		print('YES')
		winCombo = [None] * n
		for (i, c) in enumerate(s):
			if c == 'R' and wP > 0:
				wP -= 1
				dA['P'] -= 1
				winCombo[i] = 'P'
			elif c == 'P' and wS > 0:
				wS -= 1
				dA['S'] -= 1
				winCombo[i] = 'S'
			elif c == 'S' and wR > 0:
				wR -= 1
				dA['R'] -= 1
				winCombo[i] = 'R'
		left = []
		for (k, v) in dA.items():
			for j in range(v):
				left.append(k)
		i = 0
		while i < n:
			if winCombo[i] == None:
				L = left.pop()
				winCombo[i] = L
			i += 1
		print(''.join(winCombo))


import sys, math, statistics as ss, collections as cc
n = int(input())
for i in range(n):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	q = s.count('R')
	w = s.count('P')
	qq = s.count('S')
	qw = ''
	qr = ['R'] * a
	qp = ['P'] * b
	qs = ['S'] * c
	if min(a, qq) + min(b, q) + min(c, w) >= math.ceil(n / 2):
		print('YES')
		for j in range(len(s)):
			if a > 0 and s[j] == 'S':
				qw = qw + 'R'
				a = a - 1
				qr.pop()
			elif b > 0 and s[j] == 'R':
				qw = qw + 'P'
				b = b - 1
				qp.pop()
			elif c > 0 and s[j] == 'P':
				qw = qw + 'S'
				c = c - 1
				qs.pop()
			else:
				qw = qw + '.'
		q = qr + qp + qs
		qw = list(qw)
		for j in range(len(qw)):
			if qw[j] == '.':
				qw[j] = q.pop()
		print(''.join(qw))
	else:
		print('NO')


for q in range(int(input())):
	n = int(input())
	abc = [int(i) for i in input().split()]
	word = input()
	bcnt = [0, 0, 0]
	for l in word:
		if l == 'R':
			bcnt[0] += 1
		elif l == 'P':
			bcnt[1] += 1
		else:
			bcnt[2] += 1
	sm = sum([min(bcnt[i], abc[(i + 1) % 3]) for i in range(3)])
	if sm < (n + 1) // 2:
		print('NO')
		continue
	ans = []
	dic = {'R': 0, 'P': 1, 'S': 2}
	for i in range(n):
		l = word[i]
		b = (dic[l] + 1) % 3
		if abc[b] > 0:
			abc[b] -= 1
			ans.append(['R', 'P', 'S'][b])
		else:
			ans.append('0')
	for i in range(n):
		if ans[i] == '0':
			for j in range(3):
				if abc[j] > 0:
					ans[i] = ['R', 'P', 'S'][j]
					abc[j] -= 1
					break
	print('YES')
	print(''.join(ans))


for i in range(int(input())):
	a = int(input())
	s = (a + 1) // 2
	(c, d, e) = map(int, input().split())
	f = {'R': c, 'P': d, 'S': e}
	z = input()
	op = {'R': 'P', 'P': 'S', 'S': 'R'}
	an = [0] * a
	for j in range(a):
		if f[op[z[j]]]:
			an[j] = 1
			f[op[z[j]]] -= 1
	if sum(an) < s:
		print('NO')
	else:
		print('YES')
		for i in range(a):
			if an[i]:
				print(op[z[i]], end='')
			elif f['R']:
				print('R', end='')
				f['R'] -= 1
			elif f['P']:
				print('P', end='')
				f['P'] -= 1
			else:
				print('S', end='')
				f['S'] -= 1
		print()


from math import ceil
t = int(input())

def get_ans(n, r, p, s, bob, st):
	ans = [0] * n
	for (i, value) in enumerate(st):
		if value == 'P':
			if s > 0:
				ans[i] = 'S'
				s -= 1
		elif value == 'S':
			if r > 0:
				ans[i] = 'R'
				r -= 1
		elif value == 'R':
			if p > 0:
				ans[i] = 'P'
				p -= 1
	for (i, value) in enumerate(ans):
		if value == 0:
			if s > 0:
				s -= 1
				ans[i] = 'S'
			elif r > 0:
				r -= 1
				ans[i] = 'R'
			elif p > 0:
				p -= 1
				ans[i] = 'P'
	return ''.join(ans)
for _ in range(t):
	n = int(input())
	(r, p, s) = map(int, input().split())
	st = input()
	bob = {'S': 0, 'R': 0, 'P': 0}
	for i in st:
		bob[i] += 1
	need = ceil(n / 2)
	alice_win = min(bob['P'], s) + min(bob['S'], r) + min(bob['R'], p)
	if alice_win < need:
		print('NO')
	else:
		print('YES')
		ans = get_ans(n, r, p, s, bob, st)
		print(ans)


for _ in range(int(input())):
	n = int(input())
	(r, p, s) = map(int, input().split())
	a = input()
	w = min(r, a.count('S')) + min(p, a.count('R')) + min(s, a.count('P'))
	if w >= (n + 1) // 2:
		print('YES')
		b = ['?'] * n
		for i in range(n):
			if 'R' == a[i]:
				if p:
					b[i] = 'P'
					p -= 1
			elif 'P' == a[i]:
				if s:
					b[i] = 'S'
					s -= 1
			elif r:
				b[i] = 'R'
				r -= 1
		for i in range(n):
			if '?' == b[i]:
				if r:
					b[i] = 'R'
					r -= 1
				elif p:
					b[i] = 'P'
					p -= 1
				else:
					b[i] = 'S'
					s -= 1
		print(''.join(b))
	else:
		print('NO')


from collections import defaultdict
t = int(input())
who_lose = {'S': 'R', 'R': 'P', 'P': 'S'}
for _ in range(t):
	n = int(input())
	to_win = (n + 1) // 2
	(a, b, c) = map(int, input().split())
	your_fighters = {'S': c, 'R': a, 'P': b}
	commands = input()
	count_commands = defaultdict(int)
	for com in commands:
		count_commands[com] += 1
	free_to_use = []
	can_win = 0
	for com in who_lose.keys():
		count_can_win = min(your_fighters[who_lose[com]], count_commands.get(com, 0))
		can_win += count_can_win
		free_to_use.extend(who_lose[com] * (your_fighters[who_lose[com]] - count_can_win))
	if can_win >= to_win:
		print('YES')
		commands_to_win = []
		for com in commands:
			tmp = your_fighters.get(who_lose[com], 0)
			if tmp == 0:
				commands_to_win.append(free_to_use.pop())
			else:
				commands_to_win.append(who_lose[com])
				your_fighters[who_lose[com]] -= 1
		print(''.join(commands_to_win))
	else:
		print('NO')


import math
for i in range(int(input())):
	score = 0
	n = int(input())
	ans = [0 for i in range(n)]
	abc = [int(i) for i in input().split()]
	game = input()
	for j in range(n):
		if abc[1] != 0 and game[j] == 'R':
			score += 1
			abc[1] -= 1
			ans[j] = 'P'
		elif abc[2] != 0 and game[j] == 'P':
			score += 1
			abc[2] -= 1
			ans[j] = 'S'
		elif abc[0] != 0 and game[j] == 'S':
			score += 1
			abc[0] -= 1
			ans[j] = 'R'
	if score >= math.ceil(n / 2):
		print('Yes')
		for j in range(n):
			if ans[j] == 0:
				if abc[0] != 0:
					abc[0] -= 1
					ans[j] = 'R'
				elif abc[1] != 0:
					abc[1] -= 1
					ans[j] = 'P'
				elif abc[2] != 0:
					abc[2] -= 1
					ans[j] = 'S'
			print(ans[j], end='')
		print()
	else:
		print('No')


import math
t = int(input())
for _ in range(t):
	n = int(input())
	(r, p, s) = map(int, input().split())
	str = input()
	w = 0
	arr = []
	for i in str:
		if i == 'R' and p != 0:
			p -= 1
			w += 1
			arr.append('P')
		elif i == 'S' and r != 0:
			r -= 1
			w += 1
			arr.append('R')
		elif i == 'P' and s != 0:
			s -= 1
			w += 1
			arr.append('S')
		else:
			arr.append(0)
	ost = 'R' * r + 'S' * s + 'P' * p
	j = 0
	for i in range(n):
		if arr[i] == 0:
			arr[i] = ost[j]
			j += 1
	if w >= int(math.ceil(n / 2)):
		print('YES')
		print(*arr, sep='')
	else:
		print('NO')


import math
for i in range(int(input())):
	n = int(input())
	(r, p, s) = map(int, input().split())
	st = input()
	win = 0
	if st.count('S') > r:
		win += r
	else:
		win += st.count('S')
	if st.count('P') > s:
		win += s
	else:
		win += st.count('P')
	if st.count('R') > p:
		win += p
	else:
		win += st.count('R')
	if win >= math.ceil(n / 2):
		print('YES')
		ans = []
		for d in st:
			if d == 'S' and r > 0:
				ans.append('R')
				r -= 1
			elif d == 'P' and s > 0:
				ans.append('S')
				s -= 1
			elif d == 'R' and p > 0:
				ans.append('P')
				p -= 1
			else:
				ans.append(' ')
		i = 0
		for d in st:
			if ans[i] == ' ':
				if p > 0:
					ans[i] = 'P'
					p -= 1
				elif r > 0:
					ans[i] = 'R'
					r -= 1
				else:
					ans[i] = 'S'
					s -= 1
			i += 1
		print(''.join(ans))
	else:
		print('NO')


t = int(input())
for i in range(t):
	n_ = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	(A, B, C) = (s.count('R'), s.count('P'), s.count('S'))
	(m, n, p) = (min(A, b), min(B, c), min(C, a))
	if 2 * (m + n + p) < n_:
		print('No')
	else:
		print('Yes')
		print(s.replace('R', 'p', m).replace('P', 's', n).replace('S', 'r', p).replace('R', '*').replace('P', '*').replace('S', '*').replace('*', 'r', a - p).replace('*', 'p', b - m).replace('*', 's', c - n).upper())


t = int(input())
for test in range(t):
	n = int(input())
	(a, b, c) = [int(e) for e in input().split()]
	bob = input()
	(a1, b1, c1) = (0, 0, 0)
	for i in bob:
		if i == 'R':
			a1 += 1
		elif i == 'P':
			b1 += 1
		else:
			c1 += 1
	w = min(a1, b) + min(b1, c) + min(c1, a)
	if 2 * w < n:
		print('NO')
	else:
		print('YES')
		ans = ''
		for i in bob:
			if i == 'R':
				if b > 0:
					ans += 'P'
					b -= 1
				else:
					ans += '?'
			elif i == 'P':
				if c > 0:
					ans += 'S'
					c -= 1
				else:
					ans += '?'
			elif a > 0:
				ans += 'R'
				a -= 1
			else:
				ans += '?'
		ans = [e for e in ans]
		for i in range(len(ans)):
			if ans[i] == '?':
				if a > 0:
					ans[i] = 'R'
					a -= 1
				elif b > 0:
					ans[i] = 'P'
					b -= 1
				else:
					ans[i] = 'S'
					c -= 1
		print(''.join((e for e in ans)))


t = int(input())
for _ in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	seq = input()
	A = seq.count('R')
	B = seq.count('P')
	C = seq.count('S')
	count = min(a, C) + min(b, A) + min(c, B)
	string = []
	if count * 2 < n:
		print('no')
		continue
	elif count * 2 >= n:
		print('yes')
		for i in seq:
			if i == 'R' and b > 0:
				b -= 1
				string += 'P'
			elif i == 'P' and c > 0:
				c -= 1
				string += 'S'
			elif i == 'S' and a > 0:
				a -= 1
				string += 'R'
			else:
				string += '_'
		ans = ''
		for j in string:
			if j != '_':
				ans += j
			elif a > 0:
				a -= 1
				ans += 'R'
			elif b > 0:
				b -= 1
				ans += 'P'
			else:
				c -= 1
				ans += 'S'
		print(ans)


import sys
import collections
import heapq
import math
input = sys.stdin.readline

def rints():
	return map(int, input().strip().split())

def rstr():
	return input().strip()

def rint():
	return int(input().strip())

def rintas():
	return [int(i) for i in input().strip().split()]

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
t = rint()
for _ in range(t):
	n = rint()
	(a, b, c) = rints()
	s = rstr()
	yes = False
	ans = ['X' for _ in range(n)]
	cnt = 0
	for i in range(n):
		if s[i] == 'R':
			if b > 0:
				b -= 1
				cnt += 1
				ans[i] = 'P'
	for i in range(n):
		if s[i] == 'P':
			if c > 0:
				c -= 1
				cnt += 1
				ans[i] = 'S'
	for i in range(n):
		if s[i] == 'S':
			if a > 0:
				a -= 1
				cnt += 1
				ans[i] = 'R'
	nn = int(math.ceil(n / 2))
	if cnt < nn:
		print('NO')
		continue
	for i in range(n):
		if ans[i] != 'X':
			continue
		if b > 0:
			b -= 1
			ans[i] = 'P'
		elif c > 0:
			c -= 1
			ans[i] = 'S'
		elif a > 0:
			a -= 1
			ans[i] = 'R'
	print('YES')
	print(''.join(ans))


import sys
import operator
import math
q = int(input())
for _ in range(q):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	neededwins = math.ceil(n / 2)
	bb = s.count('R')
	cc = s.count('P')
	aa = s.count('S')
	outs = [0] * n
	counter = 0
	if min(aa, a) + min(bb, b) + min(cc, c) >= neededwins:
		print('YES')
		for i in range(n):
			if s[i] == 'R' and b:
				outs[i] = 'P'
				b -= 1
			elif s[i] == 'P' and c:
				outs[i] = 'S'
				c -= 1
			if s[i] == 'S' and a:
				outs[i] = 'R'
				a -= 1
		for i in range(n):
			if outs[i] == 0:
				if a:
					outs[i] = 'R'
					a -= 1
				elif b:
					outs[i] = 'P'
					b -= 1
				elif c:
					outs[i] = 'S'
					c -= 1
		print(''.join(outs))
	else:
		print('NO')


for TESTS in range(int(input())):
	n = int(input())
	(a, b, c) = map(int, input().split())
	RPS = input()
	ans = []
	WIN = 0
	for i in range(n):
		if RPS[i] == 'R' and b != 0:
			b -= 1
			ans.append('P')
			WIN += 1
		elif RPS[i] == 'P' and c != 0:
			c -= 1
			ans.append('S')
			WIN += 1
		elif RPS[i] == 'S' and a != 0:
			a -= 1
			ans.append('R')
			WIN += 1
		else:
			ans.append('')
	for i in range(n):
		if ans[i] == '':
			if a != 0:
				a -= 1
				ans[i] = 'R'
			elif b != 0:
				b -= 1
				ans[i] = 'P'
			else:
				c -= 1
				ans[i] = 'S'
	if WIN >= (n + 1) // 2:
		print('YES')
		print(*ans, sep='')
	else:
		print('NO')


from fractions import gcd
from datetime import date, timedelta
from heapq import *
import math
from collections import defaultdict, Counter, deque
import sys
from bisect import *
import itertools
import copy
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7

def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		(a, b, c) = map(int, input().split())
		s = list(input())
		p = s.count('P')
		r = s.count('R')
		ss = s.count('S')
		paa = min(b, r)
		choki = min(c, p)
		guu = min(a, ss)
		cnt = min(b, r) + min(c, p) + min(a, ss)
		(aa, bb, cc) = (0, 0, 0)
		if n % 2 == 0:
			if n // 2 > cnt:
				print('NO')
				continue
		elif n % 2 == 1:
			if n // 2 >= cnt:
				print('NO')
				continue
		print('YES')
		ans = [''] * n
		for i in range(n):
			if s[i] == 'P' and choki - cc > 0:
				ans[i] = 'S'
				cc += 1
			elif s[i] == 'R' and paa - bb > 0:
				ans[i] = 'P'
				bb += 1
			elif s[i] == 'S' and guu - aa > 0:
				ans[i] = 'R'
				aa += 1
		for i in range(n):
			if ans[i] == '':
				if c - choki > 0:
					ans[i] = 'S'
					choki += 1
				elif b - paa > 0:
					ans[i] = 'P'
					paa += 1
				elif a - guu > 0:
					ans[i] = 'R'
					guu += 1
		print(''.join(ans))
main()


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(100000000)
	threading.stack_size(40960000)
	thread = threading.Thread(target=main)
	thread.start()
from math import ceil, floor, log, sqrt, factorial
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[0]

def sort2(l):
	return sorted(l, key=getKey)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def main():
	for _ in range(ii()):
		n = ii()
		(a, b, c) = mi()
		s = si()
		ans = ''
		cnt = 0
		for i in range(n):
			if s[i] == 'R':
				if b > 0:
					ans += 'P'
					b -= 1
					cnt += 1
				else:
					ans += '.'
			if s[i] == 'P':
				if c > 0:
					ans += 'S'
					c -= 1
					cnt += 1
				else:
					ans += '.'
			if s[i] == 'S':
				if a > 0:
					ans += 'R'
					a -= 1
					cnt += 1
				else:
					ans += '.'
		if cnt >= ceil(n / 2):
			print('YES')
			for i in range(n):
				if ans[i] == '.':
					if a > 0:
						print('R', end='')
						a -= 1
					elif b > 0:
						print('P', end='')
						b -= 1
					elif c > 0:
						print('S', end='')
						c -= 1
				else:
					print(ans[i], end='')
			print()
		else:
			print('NO')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from math import ceil
for _ in range(int(input())):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	(P, S, R) = (s.count('P'), s.count('S'), s.count('R'))
	res = min(c, P) + min(b, R) + min(a, S)
	if int(res) < ceil(n / 2):
		print('NO')
		continue
	print('YES')
	l = [0] * n
	for i in range(len(s)):
		if s[i] == 'P' and c > 0:
			l[i] = 'S'
			c -= 1
		elif s[i] == 'S' and a > 0:
			l[i] = 'R'
			a -= 1
		elif s[i] == 'R' and b > 0:
			l[i] = 'P'
			b -= 1
	for i in range(len(s)):
		if l[i] == 0 and c > 0:
			l[i] = 'S'
			c -= 1
		elif l[i] == 0 and a > 0:
			l[i] = 'R'
			a -= 1
		elif l[i] == 0 and b > 0:
			l[i] = 'P'
			b -= 1
	print(''.join(map(str, l)))


n = int(input())
for _ in range(n):
	l = int(input())
	(a, b, c) = map(int, input().split())
	bobHands = str(input())
	aliceHands = ['L' for x in range(l)]
	for i in range(l):
		if bobHands[i] == 'R' and b:
			b -= 1
			aliceHands[i] = 'P'
		if bobHands[i] == 'P' and c:
			c -= 1
			aliceHands[i] = 'S'
		if bobHands[i] == 'S' and a:
			a -= 1
			aliceHands[i] = 'R'
	count = l
	for i in range(l):
		if aliceHands[i] == 'L':
			count -= 1
	if count < l / 2:
		print('NO')
	else:
		for i in range(l):
			if aliceHands[i] == 'L':
				if b:
					aliceHands[i] = 'P'
					b -= 1
					continue
				if a:
					aliceHands[i] = 'R'
					a -= 1
					continue
				if c:
					aliceHands[i] = 'S'
					c -= 1
					continue
		print('YES')
		print(''.join(aliceHands))


import math
t = int(input())
for i in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	s = input()
	a1 = s.count('R')
	b1 = s.count('P')
	c1 = s.count('S')
	ans = min(a, c1) + min(b, a1) + min(c, b1)
	a2 = a - min(a, c1)
	b2 = b - min(b, a1)
	c2 = c - min(c, b1)
	if ans >= math.ceil(n / 2):
		print('YES')
		l2 = ['1'] * n
		for i in range(n):
			elm = s[i]
			if elm == 'R':
				if b > 0:
					b -= 1
					l2[i] = 'P'
			elif elm == 'P':
				if c > 0:
					c -= 1
					l2[i] = 'S'
			elif a > 0:
				a -= 1
				l2[i] = 'R'
		j = 0
		while a > 0:
			if l2[j] == '1':
				l2[j] = 'R'
				a -= 1
			j += 1
		while b > 0:
			if l2[j] == '1':
				l2[j] = 'P'
				b -= 1
			j += 1
		while c > 0:
			if l2[j] == '1':
				l2[j] = 'S'
				c -= 1
			j += 1
		print(''.join(l2))
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	cnt = 0
	s = list(input())
	ans = ['?'] * n
	for i in range(n):
		x = s[i]
		if x == 'R' and b > 0:
			ans[i] = 'P'
			b -= 1
			cnt += 1
		if x == 'P' and c > 0:
			ans[i] = 'S'
			c -= 1
			cnt += 1
		if x == 'S' and a > 0:
			ans[i] = 'R'
			a -= 1
			cnt += 1
	for i in range(n):
		if ans[i] != '?':
			continue
		x = s[i]
		if x == 'R' and a > 0:
			ans[i] = 'R'
			a -= 1
		if x == 'P' and b > 0:
			ans[i] = 'P'
			b -= 1
		if x == 'S' and c > 0:
			ans[i] = 'S'
			c -= 1
	for i in range(n):
		if ans[i] != '?':
			continue
		if a > 0:
			ans[i] = 'R'
		if b > 0:
			ans[i] = 'P'
		if c > 0:
			ans[i] = 'S'
	if cnt >= (n + 1) // 2:
		print('YES')
		print(''.join(ans))
	else:
		print('NO')