Innokentiy likes tea very much and today he wants to drink exactly n cups of tea. He would be happy to drink more but he had exactly n tea bags, a of them are green and b are black.

Innokentiy doesn't like to drink the same tea (green or black) more than k times in a row. Your task is to determine the order of brewing tea bags so that Innokentiy will be able to drink n cups of tea, without drinking the same tea more than k times in a row, or to inform that it is impossible. Each tea bag has to be used exactly once.


-----Input-----

The first line contains four integers n, k, a and b (1 ≤ k ≤ n ≤ 10^5, 0 ≤ a, b ≤ n) — the number of cups of tea Innokentiy wants to drink, the maximum number of cups of same tea he can drink in a row, the number of tea bags of green and black tea. It is guaranteed that a + b = n.


-----Output-----

If it is impossible to drink n cups of tea, print "NO" (without quotes).

Otherwise, print the string of the length n, which consists of characters 'G' and 'B'. If some character equals 'G', then the corresponding cup of tea should be green. If some character equals 'B', then the corresponding cup of tea should be black.

If there are multiple answers, print any of them.


-----Examples-----
Input
5 1 3 2

Output
GBGBG

Input
7 2 2 5

Output
BBGBGBB
Input
4 3 4 0

Output
NO

Difficulty: MEDIUM
Tags: Greedy algorithms

Mathematics

Constructive algorithms
Skill types: Greedy algorithms

Starter code:

Solutions:
(n, k, a, b) = map(int, input().split())
m1 = max(a, b)
m2 = min(a, b)
if m1 - k * m2 > k:
	print('NO')
elif a == b:
	while a != 0:
		print('G', end='')
		print('B', end='')
		a -= 1
elif a > b:
	while b != 0 or a != 0:
		for i in range(k):
			if a == 0:
				break
			print('G', end='')
			a -= 1
			while a == b and a != 0:
				print('B', end='')
				print('G', end='')
				a -= 1
				b -= 1
		if b != 0:
			print('B', end='')
			b -= 1
			while a == b and a != 0:
				print('G', end='')
				print('B', end='')
				a -= 1
				b -= 1
elif a < b:
	while b != 0 or a != 0:
		for i in range(k):
			if b == 0:
				break
			print('B', end='')
			b -= 1
			while a == b and a != 0:
				print('G', end='')
				print('B', end='')
				a -= 1
				b -= 1
		if a != 0:
			print('G', end='')
			a -= 1
			while a == b and a != 0:
				print('B', end='')
				print('G', end='')
				a -= 1
				b -= 1


from math import ceil as ceil
(n, k, a, b) = [int(i) for i in input().strip().split()]
if (min(a, b) + 1) * k < max(a, b):
	print('NO')
else:
	(l, m) = ('G', 'B')
	if a > b:
		(l, m) = (m, l)
	s = ''
	(a, b) = (max(a, b), min(a, b))
	while a > 0 and b > 0:
		x = ceil(a / (b + 1))
		s = s + m * x
		a -= x
		if not a:
			break
		s = s + l
		b -= 1
	if a:
		s = s + m * a
	if b:
		s = s + l * b
	print(s)


(n, k, a, b) = map(int, input().split())
if a == b:
	print('GB' * (n // 2))
else:
	(maxx, minn) = (max(a, b), min(a, b))
	if maxx / (minn + 1) > k:
		print('NO')
	else:
		x = maxx // (minn + 1)
		y = maxx - (minn + 1) * x
		if a > b:
			x1 = 'G'
			x2 = 'B'
		else:
			x1 = 'B'
			x2 = 'G'
		arr = [x1 * x for i in range(minn + 1)]
		for i in range(y):
			arr[i] += x1
		print(x2.join(arr))


(n, k, a, b) = map(int, input().split())
s = 'GB' * min(a, b)
a -= len(s) // 2
b -= len(s) // 2
if a != 0:
	s += 'G'
	a -= 1
elif b != 0:
	s = 'B' + s
	b -= 1
cur = 0
m = 1
while cur != len(s):
	if m != k:
		if s[cur] == 'G' and a != 0:
			s = s[:cur + 1] + 'G' + s[cur + 1:]
			a -= 1
			m += 1
		elif s[cur] == 'B' and b != 0:
			s = s[:cur + 1] + 'B' + s[cur + 1:]
			b -= 1
			m += 1
	else:
		m = 1
	cur += 1
if a == 0 and b == 0:
	print(s)
else:
	print('NO')


(n, k, a, b) = [int(i) for i in input().split()]
s = ''
mx = 0
mn = 0
cmx = ''
cmn = ''
if a >= b:
	mx = a
	mn = b
	cmx = 'G'
	cmn = 'B'
else:
	mx = b
	mn = a
	cmx = 'B'
	cmn = 'G'
if mx / (mn + 1) > k:
	s = 'NO'
elif k >= mx:
	s = cmx * mx + cmn * mn
elif mx == 1:
	s += cmx * mx + cmn * mn
else:
	leftmin = mn % ((mx - 1) // k)
	for i in range((mx - 1) // k):
		s += cmx * k + cmn * (mn // ((mx - 1) // k))
		if leftmin > 0:
			if leftmin >= k - mn // ((mx - 1) // k):
				leftmin -= k - mn // ((mx - 1) // k)
				s += cmn * (k - mn // ((mx - 1) // k))
			else:
				s += cmn * leftmin
				leftmin = 0
	s += cmx * (mx - (mx - 1) // k * k) + cmn * leftmin
print(s)


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')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 10 ** 9 + 7
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

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

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

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
(n, k, a, b) = value()
first = 'G'
second = 'B'
if a < b:
	(first, second) = (second, first)
	(a, b) = (b, a)
ok = True
ans = []
for i in range(a):
	if i % k == 0 and i > 0:
		if b == 0:
			ok = False
		ans.append(second)
		b -= 1
	ans.append(first)
if not ok:
	print('NO')
	exit()
seq = []
n = len(ans)
i = 0
while i < n - 1:
	seq.append(first)
	if ans[i] == first and ans[i + 1] == second:
		here = min(k - 1, b)
		b -= here
		for _ in range(here + 1):
			seq.append(second)
		i += 2
	else:
		here = min(k, b)
		b -= here
		for _ in range(here):
			seq.append(second)
		i += 1
seq.append(first)
seq += [second] * min(k, b)
b -= min(k, b)
seq = [second] * min(k, b) + seq
b -= min(k, b)
if b == 0:
	print(*seq, sep='')
else:
	print('NO')


from collections import *
d = defaultdict()
(n, k, a, b) = map(int, input().split())
ch = 1
if a == b:
	ch = 2
(mx, mn) = (max(a, b), min(a, b))
if a > b:
	d[mx] = 'G'
	d[mn] = 'B'
else:
	d[mx] = 'B'
	d[mn] = 'G'
o = -(-mx // (mn + 1))
if o > k:
	ch = 0
s = ''
t = mn
y = mx
o = mx // (mn + 1)
y = mx - (mn + 1) * o
a = []
if ch == 2:
	s = ''
	for i in range(n // 2):
		s += 'GB'
	print(s)
elif ch == 1:
	for i in range(mn + 1):
		a.append(d[mx] * o)
	for i in range(y):
		a[i] += d[mx]
	s = d[mn].join(a)
	print(s)
else:
	print('NO')


import os
import sys
from io import BytesIO, IOBase

def main():
	(n, k, a, b) = map(int, input().split(' '))
	ans = []
	while a > 0 and b > 0:
		if a > b:
			if a - k >= b:
				a = a - k
				b = b - 1
				ans.append('G' * k)
				ans.append('B')
			else:
				ans.append('G' * (a - b))
				ans.append('B')
				a = b
				b -= 1
		elif b - k >= a:
			b = b - k
			a = a - 1
			ans.append('B' * k)
			ans.append('G')
		else:
			ans.append('B' * (b - a))
			ans.append('G')
			b = a
			a -= 1
	if a <= k and b == 0:
		ans.append('G' * a)
		a = 0
	if b <= k and a == 0:
		ans.append('B' * b)
		b = 0
	if a != 0 or b != 0:
		print('NO')
	else:
		print(''.join(ans))
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()


(n, k, a, b) = tuple((int(_) for _ in input().split()))
tea_string = ''
(g_tea, b_tea) = ('G', 'B')
if b > a:
	(a, b) = (b, a)
	(g_tea, b_tea) = (b_tea, g_tea)
for _ in range(n):
	if _ % 2 == 0:
		if a > b >= 0:
			tea_string += g_tea * max(0, min(a, k))
			a -= max(0, min(a, k))
		elif a > 0:
			tea_string += g_tea
			a -= 1
	elif b > a >= 0:
		tea_string += b_tea * max(0, min(b, k))
		b -= max(0, min(b, k))
	elif b > 0:
		tea_string += b_tea
		b -= 1
if tea_string.count(g_tea * (k + 1)) > 0 or tea_string.count(g_tea * (k + 1)) > 0 or len(tea_string) != n:
	print('NO')
else:
	print(tea_string)


import math
(n, k, a, b) = map(int, input().split(' '))
fail = False
lar = max(a, b)
sml = min(a, b)
s = math.ceil(lar / k)
if s - 1 > sml:
	fail = True
if a > b:
	remain_G = a
	remain_B = b
	order = ''
	if (s - 1) * k < b:
		order = min(k, remain_B) * 'B'
		remain_B -= min(k, remain_B)
	if s == 1:
		num_of_b = remain_B
	else:
		num_of_b = math.floor(remain_B / (s - 1))
	while remain_G > 0:
		if remain_G <= k:
			order += remain_G * 'G'
			remain_G -= remain_G
		else:
			order += k * 'G'
			order += num_of_b * 'B'
			remain_G -= k
			remain_B -= num_of_b
	rep_str = 'G' + num_of_b * 'B' + 'G'
	new_str = 'G' + (num_of_b + 1) * 'B' + 'G'
	order = order.replace(rep_str, new_str, remain_B)
else:
	remain_G = a
	remain_B = b
	order = ''
	if (s - 1) * k < a:
		order = min(k, remain_G) * 'G'
		remain_G -= min(k, remain_G)
	if s == 1:
		num_of_g = remain_G
	else:
		num_of_g = math.floor(remain_G / (s - 1))
	while remain_B > 0:
		if remain_B <= k:
			order += remain_B * 'B'
			remain_B -= remain_B
		else:
			order += k * 'B'
			order += num_of_g * 'G'
			remain_B -= k
			remain_G -= num_of_g
	rep_str = 'B' + num_of_g * 'G' + 'B'
	new_str = 'B' + (num_of_g + 1) * 'G' + 'B'
	order = order.replace(rep_str, new_str, remain_G)
if fail:
	print('NO')
else:
	print(order)


from math import ceil
(n, k, g, b) = map(int, input().split())
if (min(g, b) + 1) * k < max(g, b):
	print('NO')
	exit()
if g > b:
	m = ceil(g / k)
	left = b
	for i in range(m - 1):
		print('G' * k, end='')
		if left - k >= m - i - 1:
			print('B' * k, end='')
			left -= k
		else:
			print('B', end='')
			left -= 1
	print('G' * (g - k * (m - 1)), end='')
	print('B' * left)
else:
	m = ceil(b / k)
	left = g
	for i in range(m - 1):
		print('B' * k, end='')
		if left - k >= m - i - 1:
			print('G' * k, end='')
			left -= k
		else:
			print('G', end='')
			left -= 1
	print('B' * (b - k * (m - 1)), end='')
	print('G' * left)


from sys import stdin, stdout
(n, k, a, b) = map(int, stdin.readline().split())
a_min = (a - 1) // k + 1
b_min = (b - 1) // k + 1
if b_min <= a_min <= b + 1 or a_min <= b_min <= a + 1:
	while a > 0 or b > 0:
		if a - b >= k:
			stdout.write(str('G' * k))
			stdout.write(str('B' * min(1, b)))
			b -= min(1, b)
			a -= k
		elif b - a >= k:
			stdout.write(str('B' * k))
			stdout.write(str('G' * min(1, a)))
			b -= k
			a -= min(1, a)
		elif 0 < a - b < k:
			stdout.write(str('G' * (a - b)))
			stdout.write(str('B' * min(1, b)))
			a -= a - b
			b -= min(1, b)
		elif 0 < b - a < k:
			stdout.write(str('B' * (b - a)))
			stdout.write(str('G' * min(1, a)))
			b -= b - a
			a -= min(1, a)
		elif a == b != 0:
			stdout.write(str('BG' * a))
			a = b = 0
else:
	stdout.write('NO')


(n, k, a, b) = map(int, input().split())
s = ''
g = False
if a > b:
	g = True
i = 0
while i < n:
	if g:
		if b == 0 and a > k:
			print('NO')
			exit()
		if a > b:
			c = k
			if a < k:
				c = a
			s += c * 'G'
			i += c
			a -= c
		else:
			s += 'G'
			a -= 1
			i += 1
	else:
		if a == 0 and b > k:
			print('NO')
			exit()
		if a < b:
			c = k
			if b < k:
				c = b
			s += c * 'B'
			i += c
			b -= c
		else:
			s += 'B'
			b -= 1
			i += 1
	g = not g
	if a == 0 and b == 0:
		break
print(s)


(n, k, a, b) = map(int, input().split())
ans = ''
(gr, le) = (max(a, b), min(a, b))
possible = True
count = 0
while gr > le and le and gr:
	ans += '1'
	gr -= 1
	count += 1
	if count == k:
		count = 0
		le -= 1
		ans += '0'
if gr == le:
	ans += '01' * gr
elif not le:
	if gr > k:
		possible = False
	ans += '1' * gr
if possible:
	t = 'GB' if a > b else 'BG'
	print(ans.translate(str.maketrans('10', t)))
else:
	print('NO')


(n, k, a, b) = map(int, input().split())
if a == 0:
	if b > k:
		print('NO')
	else:
		print('B' * b)
elif b == 0:
	if a > k:
		print('NO')
	else:
		print('G' * a)
elif a == b:
	ans = ''
	while a > 0 or b > 0:
		if a >= k:
			ans += 'G' * k
			a -= k
		elif a > 0:
			ans += 'G' * a
			a = 0
		if b >= k:
			ans += 'B' * k
			b -= k
		elif b > 0:
			ans += 'B' * b
			b = 0
	print(ans)
elif a < b:
	x = b // (a + 1)
	y = x + (1 if b % (a + 1) > 0 else 0)
	if y > k:
		print('NO')
	else:
		z = b % (a + 1)
		ans = ''
		while a > 0 or b > 0:
			if b > 0:
				if b >= x:
					ans += 'B' * x
					b -= x
					if z > 0:
						ans += 'B'
						b -= 1
						z -= 1
				else:
					ans += 'B' * b
					b = 0
			if a > 0:
				ans += 'G'
				a -= 1
		print(ans)
else:
	x = a // (b + 1)
	y = x + (1 if a % (b + 1) > 0 else 0)
	if y > k:
		print('NO')
	else:
		z = a % (b + 1)
		ans = ''
		while a > 0 or b > 0:
			if a > 0:
				if a > x:
					ans += 'G' * x
					a -= x
					if z > 0:
						ans += 'G'
						a -= 1
						z -= 1
				else:
					ans += 'G' * a
					a = 0
			if b > 0:
				ans += 'B'
				b -= 1
		print(ans)


(n, k, a, b) = [int(x) for x in input().split()]
if int(n / (k + 1)) > min(a, b):
	print('NO')
else:
	actual = a >= b
	s = ''
	letter = ''
	m = 0
	while n > 0:
		v = int(n / (k + 1))
		if v < min(a, b):
			if actual:
				m = min(k, a - v)
				letter = 'G'
				a -= m
			else:
				m = min(k, b - v)
				letter = 'B'
				b -= m
		elif v == min(a, b):
			if a == b:
				m = a
				if actual:
					letter = 'GB'
				else:
					letter = 'BG'
			elif actual:
				m = max(min(k, a - v), 1)
				letter = 'G'
				a -= m
			else:
				m = max(min(k, b - v), 1)
				letter = 'B'
				b -= m
		actual = not actual
		s += letter * m
		n -= m * len(letter)
	print(s)


inp = str(input())
(n, k, G, B) = list(map(int, inp.split(' ')))
c = ['G', 'B']
l = [G, B]
import math
res = ''
i = 0
if B > G:
	i = 1
while True:
	if l == [0, 0]:
		print(res)
		break
	other = 1 - i
	x = min([l[i], k, l[i] - math.ceil(l[other] * 1.0 / k) + 1])
	if x <= 0:
		print('NO')
		break
	res += c[i] * x
	l[i] -= x
	i = 1 - i


(a, b, c, d) = map(int, input().split())
L = ['G', 'B']
if d > c:
	L = L[::-1]
	(c, d) = (d, c)
s = ''
k = a
while k > 0:
	if c >= d:
		m = min(b, k, c)
		s += L[0] * m
		k -= m
		c -= m
	else:
		s += L[0]
		k -= 1
		c -= 1
	if c <= d:
		m = min(b, k, d)
		s += L[1] * m
		k -= m
		d -= m
	else:
		s += L[1]
		k -= 1
		d -= 1
	if c < 0 or d < 0:
		print('NO')
		exit()
print(s)


(n, k, a, b) = [int(i) for i in input().split()]
if a > b:
	max_char = 'G'
	min_char = 'B'
else:
	max_char = 'B'
	min_char = 'G'
maxab = max(a, b)
minab = min(a, b)
ans_string = ''
exit_flag = False
no_flag = False
while maxab != minab and minab > 0:
	num_move = min(k, maxab - minab)
	ans_string += max_char * num_move + min_char
	maxab -= num_move
	minab -= 1
	n -= num_move + 1
	if maxab > k and minab == 0:
		exit_flag = True
		no_flag = True
		print('NO')
		break
if maxab > k and minab == 0 and (not no_flag):
	exit_flag = True
	print('NO')
if not exit_flag:
	if maxab == minab:
		ans_string += (max_char + min_char) * maxab
		minab = 0
		maxab = 0
	if maxab > 0:
		ans_string += max_char * maxab
	print(ans_string)


(n, k, a, b) = [int(i) for i in input().split()]
ans = []
if a >= b:
	gr = [k] * (a // k)
	if a % k > 0:
		gr.append(a % k)
	if len(gr) > 1:
		x = b // len(gr)
		y = b % len(gr)
		bl = [x + 1] * y + [x] * (len(gr) - y)
	else:
		bl = [b]
	for i in range(len(gr)):
		ans.extend(['G'] * gr[i])
		ans.extend(['B'] * bl[i])
else:
	gr = [k] * (b // k)
	if b % k > 0:
		gr.append(b % k)
	if len(gr) > 1:
		x = a // len(gr)
		y = a % len(gr)
		bl = [x + 1] * y + [x] * (len(gr) - y)
	else:
		bl = [a]
	for i in range(len(gr)):
		ans.extend(['B'] * gr[i])
		ans.extend(['G'] * bl[i])
ans = ''.join(ans)
if 'G' * (k + 1) in ans or 'B' * (k + 1) in ans:
	print('NO')
else:
	print(ans)


(n, k, a, b) = map(int, input().split())
x = 'B'
y = 'G'
if a > b:
	(a, b) = (b, a)
	(x, y) = (y, x)
if (a + 1) * k < b:
	print('NO')
else:
	num = 0
	i = 0
	while i < n:
		if b > a and num < k:
			print(x, end='')
			b -= 1
			num += 1
			i += 1
		else:
			print(y, end='')
			a -= 1
			num = 0
			i += 1


(n, k, a, b) = map(int, input().split())
A = []
per = 0
if a >= b:
	per = 0
	while True:
		if b == 0:
			if a <= k:
				A.append('G' * a)
				break
			else:
				per = 1
				break
		elif a - b >= k - 1:
			a -= k
			b -= 1
			A.append('G' * k + 'B')
		elif a - b > 0:
			A.append((a - b + 1) * 'G' + 'B')
			a -= a - b + 1
			b -= 1
		else:
			A.append('GB' * a)
			break
else:
	(a, b) = (b, a)
	per = 0
	while True:
		if b == 0:
			if a <= k:
				A.append('B' * a)
				break
			else:
				per = 1
				break
		elif a - b >= k - 1:
			a -= k
			b -= 1
			A.append('B' * k + 'G')
		elif a - b > 0:
			A.append((a - b + 1) * 'B' + 'G')
			a -= a - b + 1
			b -= 1
		else:
			A.append('BG' * a)
			break
if per == 1:
	print('NO')
else:
	print(''.join(map(str, A)))


(n, k, g, b) = map(int, input().split())
if g >= b:
	gs = 'G'
	bs = 'B'
else:
	(g, b) = (b, g)
	gs = 'B'
	bs = 'G'
if g - k * b > k:
	print('NO')
else:
	gblock = g // (b + 1)
	i = g % (b + 1)
	result = ''
	for j in range(b):
		result += gs * gblock
		if i > 0:
			i -= 1
			result += gs
		result += bs
	result += gs * gblock
	print(result)


(n, k, a, b) = [int(i) for i in input().split()]
check = False
if a > b:
	(a, b) = (b, a)
	check = True
res = ''
cr = 1
cA = True
while a > 0 or b > 0:
	if a == b:
		break
	if cr == 1:
		if a <= b:
			u = min(k, b - a)
			b -= u
			res += u * '1'
		elif b == 0:
			cA = False
			break
		else:
			b -= 1
			res += '1'
		cr = 0
	else:
		if a >= b:
			u = min(k, a - b)
			a -= u
			res += u * '0'
		elif a == 0:
			cA = False
			break
		else:
			a -= 1
			res += '0'
		cr = 1
if a == b:
	if len(res) > 0:
		if res[len(res) - 1] == '0':
			res += '10' * a
		else:
			res += '01' * a
	else:
		res += '01' * a
if b == 0 and a > k:
	cA = False
if a == 0 and b > k:
	cA = False
if cA == False:
	print('NO')
elif check:
	for i in res:
		if i == '1':
			print('G', end='')
		else:
			print('B', end='')
else:
	for i in res:
		if i == '1':
			print('B', end='')
		else:
			print('G', end='')


def solve():
	(n, max_in_a_row, a, b) = map(int, input().split())
	a_char = 'G'
	b_char = 'B'
	if a < b:
		(a, b) = (b, a)
		(a_char, b_char) = (b_char, a_char)
	a_full_chunk_count = a // max_in_a_row
	total_chunk_count_a = a_full_chunk_count
	if max_in_a_row * a_full_chunk_count < a:
		total_chunk_count_a += 1
	if total_chunk_count_a - 1 > b:
		return 'NO'
	result = []
	for i in range(a_full_chunk_count):
		a -= max_in_a_row
		result.append(a_char * max_in_a_row)
		if b >= a_full_chunk_count - i + max_in_a_row:
			result.append(b_char * max_in_a_row)
			b -= max_in_a_row
		elif b > 0:
			result.append(b_char)
			b -= 1
	result.append(b_char * b)
	result.append(a_char * a)
	return ''.join(result)
print(solve())


(n, k, a, b) = map(int, input().split())
swapped = False
if a < b:
	(a, b) = (b, a)
	swapped = True
maxA = (b + 1) * k
if a > maxA:
	print('NO')
	exit()
ans = ''
restK = k
while a != b:
	if restK == 0:
		ans += 'B'
		b -= 1
		restK = k
		continue
	ans += 'G'
	a -= 1
	restK -= 1
while b > 0:
	ans += 'BG'
	b -= 1
	a -= 1
if swapped:
	ans = map(lambda c: 'G' if c == 'B' else 'B', ans)
	ans = ''.join(list(ans))
print(ans)


(n, k, a, b) = map(int, input().split())
if a == b:
	print('GB' * (n // 2))
else:
	(ma, mi) = (max(a, b), min(a, b))
	if ma / (mi + 1) > k:
		print('NO')
	else:
		x = ma // (mi + 1)
		z = ma - (mi + 1) * x
		x1 = 'G' if a > b else 'B'
		x2 = 'B' if a > b else 'G'
		ans = [x1 * x for i in range(mi + 1)]
		for i in range(z):
			ans[i] += x1
		print(x2.join(ans))


(n, k, a, b) = [int(i) for i in input().split(' ')]
last_was_green = a < b
ans = []
while a > 0 or b > 0:
	if a > b:
		if last_was_green:
			if b > 0:
				ans.append('B')
				b -= 1
				last_was_green = False
			else:
				break
		else:
			to_drink = min(a - b, k)
			ans.append('G' * to_drink)
			a -= to_drink
			last_was_green = True
	elif b > a:
		if last_was_green:
			to_drink = min(b - a, k)
			ans.append('B' * to_drink)
			b -= to_drink
			last_was_green = False
		elif a > 0:
			ans.append('G')
			a -= 1
			last_was_green = True
		else:
			break
	else:
		if last_was_green:
			ans.append('BG' * b)
		else:
			ans.append('GB' * b)
		a = b = 0
if a == 0 and b == 0:
	print(''.join(ans))
else:
	print('NO')


(n, k, a, b) = map(int, input().split())
acol = 'G'
bcol = 'B'
if a > b:
	(a, b) = (b, a)
	(acol, bcol) = (bcol, acol)
if b > (a + 1) * k:
	print('NO')
else:
	s = ''
	num = 0
	for i in range(n):
		if b > a and num < k:
			print(bcol, end='')
			b -= 1
			num += 1
		else:
			print(acol, end='')
			a -= 1
			num = 0


def main():
	try:
		while True:
			(n, k, g, b) = map(int, input().split())
			if g >= b:
				(green, black) = 'GB'
			else:
				(g, b) = (b, g)
				(green, black) = 'BG'
			result = []
			for i in range(k):
				if g == b:
					break
				result.append(green)
				g -= 1
			cur = black
			while g or b:
				if cur == black:
					if not b:
						print('NO')
						break
					if g > b:
						b -= 1
						result.append(black)
					else:
						for i in range(min(b, k)):
							result.append(black)
						b -= min(b, k)
					cur = green
				else:
					if not g:
						print('NO')
						break
					if b > g:
						g -= 1
						result.append(green)
					else:
						for i in range(min(g, k)):
							result.append(green)
						g -= min(g, k)
					cur = black
			else:
				print(''.join(result))
	except EOFError:
		pass
main()


from collections import defaultdict
import sys, os, math
(n, k, a, b) = list(map(int, input().split()))
ans = ''
while a != b and a != 0 and (b != 0):
	t = min(k, abs(a - b))
	if a > b:
		a -= t
		ans += 'G' * t + 'B'
		b -= 1
	else:
		b -= t
		ans += 'B' * t + 'G'
		a -= 1
if a == 0 and b > k or (b == 0 and a > k):
	print('NO')
	sys.exit(0)
elif a == 0:
	ans += 'B' * b
elif b == 0:
	ans += 'G' * a
elif len(ans) > 0 and ans[-1] == 'B':
	ans += 'GB' * a
else:
	ans += 'BG' * a
print(ans)


(n, k, a, b) = map(int, input().split())
if a == b:
	print('GB' * a)
elif a < b:
	if k * (a + 1) < b:
		print('NO')
	else:
		ans = [[k, 1] for _ in range(a)] + [[k, 0]]
		x = k * (a + 1)
		for i in range(a + 1):
			if x == b:
				break
			if x - b >= k - 1:
				x -= k - 1
				ans[i][0] = 1
			else:
				ans[i][0] -= x - b
				break
		tans = []
		for i in range(a + 1):
			tans.append('B' * ans[i][0])
			tans.append('G' * ans[i][1])
		print(''.join(tans))
elif k * (b + 1) < a:
	print('NO')
else:
	ans = [[k, 1] for _ in range(b)] + [[k, 0]]
	x = k * (b + 1)
	for i in range(b + 1):
		if x == a:
			break
		if x - a >= k - 1:
			x -= k - 1
			ans[i][0] = 1
		else:
			ans[i][0] -= x - a
			break
	tans = []
	for i in range(b + 1):
		tans.append('G' * ans[i][0])
		tans.append('B' * ans[i][1])
	print(''.join(tans))


(n, k, a, b) = map(int, input().split())
if a > b:
	(a, b) = (b, a)
	i = 0
	now = 'b'
	ans = []
	while i < n:
		if now == 'b':
			j = 0
			while j < k and b - a > 0 and (b > 0):
				ans += ['G']
				i += 1
				b -= 1
				j += 1
			if j == 0 and b == 0:
				print('NO')
				exit(0)
			now = 'a'
		else:
			if a == 0:
				print('NO')
				exit(0)
			ans += ['B']
			a -= 1
			i += 1
			now = 'b'
	print(''.join(ans))
else:
	i = 0
	now = 'b'
	ans = []
	while i < n:
		if now == 'b':
			j = 0
			while j < k and b - a > 0 and (b > 0):
				ans += ['G']
				i += 1
				b -= 1
				j += 1
			if j == 0 and b == 0:
				print('NO')
				exit(0)
			now = 'a'
		else:
			if a == 0:
				print('NO')
				exit(0)
			ans += ['B']
			a -= 1
			i += 1
			now = 'b'
	ans2 = []
	for i in ans:
		if i == 'G':
			ans2 += ['B']
		else:
			ans2 += ['G']
	print(''.join(ans2))


(n, k, a, b) = map(int, input().split())
s = ''
mx = max(a, b)
mn = min(a, b)
if mx - mn * k > k or (mx == 0 and mn == 0):
	print('NO')
elif abs(a - b) < k:
	if mx == a:
		s = s + ('G' * k + 'B' * k) * (mn // k) + 'G' * min(a - mn // k * k, k) + 'B' * (b - mn // k * k) + 'G' * (a - mn // k * k - k)
	else:
		s = s + ('B' * k + 'G' * k) * (mn // k) + 'B' * min(b - mn // k * k, k) + 'G' * (a - mn // k * k) + 'B' * (b - mn // k * k - k)
elif mx == a:
	if k == 1:
		while b != 0:
			s = s + 'G' + 'B'
			b = b - 1
		s = s + 'G'
	else:
		while abs(a - b) >= k and b != 0:
			s = s + 'G' * k + 'B'
			a = a - k
			b = b - 1
		mn = min(a, b)
		s = s + ('G' * k + 'B' * k) * (mn // k) + 'G' * min(a - mn // k * k, k) + 'B' * (b - mn // k * k) + 'G' * (a - mn // k * k - k)
elif k == 1:
	while a != 0:
		s = s + 'B' + 'G'
		b = b - 1
	s = s + 'B'
else:
	while abs(a - b) >= k and a != 0:
		s = s + 'B' * k + 'G'
		b = b - k
		a = a - 1
	mn = min(a, b)
	s = s + ('B' * k + 'G' * k) * (mn // k) + 'B' * min(b - mn // k * k, k) + 'G' * (a - mn // k * k) + 'B' * (b - mn // k * k - k)
print(s)


(n, k, a, b) = map(int, input().split())
if (max(a, b) - 1) // k > min(a, b):
	print('NO')
	exit()
s = []
kab = [0, 0]
for i in range(n):
	if a >= b:
		if kab[0] < k:
			s.append('G')
			kab[0] += 1
			kab[1] = 0
			a -= 1
		else:
			s.append('B')
			kab[0] = 0
			kab[1] += 1
			b -= 1
	elif kab[1] < k:
		s.append('B')
		kab[0] = 0
		kab[1] += 1
		b -= 1
	else:
		s.append('G')
		kab[0] += 1
		kab[1] = 0
		a -= 1
print(*s, sep='')


(n, k, a, b) = map(int, input().split())
(f, s) = ('G', 'B')
if b > a:
	(a, b) = (b, a)
	(f, s) = (s, f)
if a > (b + 1) * k:
	print('NO')
elif a < k:
	print(f * a + s * b)
else:
	ans = [0] * (n + 1000)
	ans[0] = k
	a -= k
	i = 1
	while a > k:
		b -= 1
		a -= k
		ans[i] = 1
		ans[i + 1] = k
		i += 2
	l = i - 1
	if a:
		ans[i] = 1
		ans[i + 1] = a
		b -= 1
		a = 0
		l += 2
	i = 1
	while b > k - ans[i]:
		b -= k - ans[i]
		ans[i] = k
		i += 2
	ans[i] += b
	l = max(l, i)
	for i in range(l + 1):
		if not i % 2:
			print(f * ans[i], end='')
		else:
			print(s * ans[i], end='')


(n, k, a, b) = [int(i) for i in input().split()]
t = abs(a - b)
chk = max(1, k - 1)
ans = ''
if a == b:
	ans = 'BG' * ((n + 1) // 2)
elif a > b:
	ans += ('G' * k + 'B') * (t // chk)
	ans += 'G' * max(1, t % chk) + 'B'
	ans += 'GB' * (n // 2)
else:
	ans += ('B' * k + 'G') * (t // chk)
	ans += 'B' * max(1, t % chk) + 'G'
	ans += 'BG' * (n // 2)
ans = ans[:n]
print(ans if ans.count('G') == a else 'NO')


import sys
import math

def main():
	(n, k, a, b) = map(int, sys.stdin.readline().split())
	g = 'G'
	bl = 'B'
	if a > b:
		(a, b) = (b, a)
		(g, bl) = (bl, g)
	if n + 1 > (k + 1) * (a + 1):
		print('NO')
		return
	r = [bl] * n
	if a == 0:
		print(''.join(r))
		return
	x = n // (a + 1) + 1
	c = 0
	for i in range(x - 1, n, x):
		r[i] = g
		c += 1
	ki = 0
	i = 0
	while i < n:
		if r[i] == bl:
			if ki == k:
				ki = 0
			else:
				if c == a:
					break
				ki += 1
				r[i] = g
				c += 1
		elif ki == k:
			ki = 0
			r[i] = bl
			c -= 1
		else:
			ki += 1
		i += 1
	print(''.join(r))
main()


x = input()
(n, k, a, b) = list(map(int, x.strip().split()))
pijem = ''
G = 'G'
B = 'B'
flag = True
while (a > 0 or b > 0) and flag:
	if a == 0:
		if b <= k:
			pijem += b * B
			b = b - b
		else:
			flag = False
			break
	elif b == 0:
		if a <= k:
			pijem += a * G
			a = a - a
		else:
			flag = False
			break
	elif a == b:
		pijem += a * (G + B)
		a = 0
		b = 0
	elif a + b <= k:
		pijem += a * G + b * B
		a = 0
		b = 0
	else:
		if a > b:
			razlika = a - b
			if razlika > k:
				koliko = min(a, k)
				pijem += koliko * G + B
				a -= koliko
				b -= 1
			else:
				koliko = min(a, razlika)
				pijem += koliko * G + B
				a -= koliko
				b -= 1
		if b > a:
			razlika = b - a
			if razlika > k:
				koliko = min(b, k)
				pijem += koliko * B + G
				a -= 1
				b -= koliko
			else:
				koliko = min(b, razlika)
				pijem += koliko * B + G
				a -= 1
				b -= koliko
if flag:
	print(pijem)
else:
	print('NO')


from sys import stdin, stdout
(n, k, g, b) = map(int, stdin.readline().split())
label = 1
ans = ''
if k == 1 and abs(g - b) > 1:
	label = 0
else:
	if g < b:
		p = 'g'
	else:
		p = 'b'
	while g or b:
		if p == 'g' and (not b) or (p == 'b' and (not g)):
			label = 0
			break
		if p == 'g':
			if b >= g:
				ans += 'B' * min(k, b)
				b = max(0, b - k)
			else:
				ans += 'B'
				b -= 1
			p = 'b'
		else:
			if g >= b:
				ans += 'G' * min(g, k)
				g = max(0, g - k)
			else:
				ans += 'G'
				g -= 1
			p = 'g'
if label:
	stdout.write(ans)
else:
	stdout.write('NO')


(n, k, a, b) = [int(i) for i in input().split()]
G = 'G'
B = 'B'
if a < b:
	(G, B) = (B, G)
	(a, b) = (b, a)
if a / (b + 1) > k or b / (a + 1) > k:
	print('NO')
else:
	while a + b > 0:
		if a - b >= k:
			print(G * k, end='')
			a -= k
			if b > 0:
				print(B, end='')
				b -= 1
		else:
			if a > 0:
				print(G, sep='', end='')
				a -= 1
			if b > 0:
				print(B, end='')
				b -= 1


(n, k, a, b) = [int(i) for i in input().split()]
ans = ''
if abs(a - b) <= 1:
	if a >= b:
		(f, s) = ('G', 'B')
	else:
		(f, s) = ('B', 'G')
	for i in range(n):
		if i % 2 == 0:
			ans += f
		else:
			ans += s
	print(ans)
	exit(0)
(cnt, f, s) = (0, 'G', 'B')
if a < b:
	(f, s) = ('B', 'G')
c = max(a, b) // min(a + 1, b + 1)
if c > k:
	print('NO')
	exit(0)
r = max(a, b) % min(a + 1, b + 1)
if r > 0 and c == k:
	print('NO')
	exit(0)
x = 0
for i in range(n):
	if x + 1 <= c:
		ans += f
		x += 1
	elif r > 0 and x == c:
		ans += f
		x += 1
		r -= 1
	else:
		ans += s
		x = 0
print(ans)


(n, k, a, b) = map(int, input().split())
x = min(a, b)
y = max(a, b)
z = (y + x) // (x + 1)
str = ''
if z > k:
	print('NO')
	exit()
if x == a:
	s1 = 'G'
	s2 = 'B'
else:
	s1 = 'B'
	s2 = 'G'
num = y - (x + 1)
cnt = 0
for i in range(x + 1):
	if cnt < y:
		str += s2
		cnt += 1
	for j in range(min(num, k - 1)):
		str += s2
		num -= 1
		cnt += 1
	if i != x:
		str += s1
print(str)


def ex():
	print('NO')
	exit()
(n, k, a, b) = list(map(int, input().split()))
rep = 1
ans = ['' for i in range(n + 1)]
ans[1] = 'G' if a > b else 'B'
if a > b:
	a -= 1
else:
	b -= 1
for i in range(2, n + 1):
	if rep == k:
		last = ans[i - 1] == 'G'
		if last and b <= 0 or (not last and a <= 0):
			ex()
		if last:
			b -= 1
			ans[i] = 'B'
		else:
			a -= 1
			ans[i] = 'G'
		rep = 1
		continue
	if a > b:
		a -= 1
		ans[i] = 'G'
	else:
		b -= 1
		ans[i] = 'B'
	if ans[i] == ans[i - 1]:
		rep += 1
print(''.join(ans[1:]))


(n, k, a, b) = map(int, input().split())
green = a > b
if a > b:
	res = 'G'
	a -= 1
	curg = 1
	curb = 0
else:
	res = 'B'
	b -= 1
	curg = 0
	curb = 1
prev = None
for i in range(n - 1):
	prev = green
	if a > b:
		if curg + 1 <= k:
			green = True
		else:
			green = False
	elif curb + 1 <= k:
		green = False
	else:
		green = True
	if green:
		if a >= 1:
			a -= 1
			res += 'G'
			if prev == green:
				curg += 1
			else:
				curg = 1
				curb = 0
		else:
			print('NO')
			break
	elif b >= 1:
		b -= 1
		res += 'B'
		if prev == green:
			curb += 1
		else:
			curb = 1
			curg = 0
	else:
		print('NO')
		break
else:
	print(res)


(n, k, a, b) = map(int, input().split())
ca = 'G'
cb = 'B'
if a < b:
	(a, b) = (b, a)
	(ca, cb) = (cb, ca)
if k > 1 and a > b + 1:
	v1 = (a - b - 1) // (k - 1)
	v2 = (a - b - 1) % (k - 1)
	if not v2:
		v2 = k - 1
		v1 -= 1
	v3 = b - v1
	if v3 < 0:
		print('NO')
	else:
		print((ca * k + cb) * v1 + (ca + cb) * v3 + ca * (v2 + 1))
elif a - b > 1:
	print('NO')
else:
	print((ca + cb) * b + ca * (a - b))


data = [int(x) for x in input().split()]
n = data[0]
k = data[1]
g = data[2]
b = data[3]
tea = ''
if g == 0:
	if n == k:
		print('B' * n)
	else:
		print('NO')
elif b == 0:
	if n == k:
		print('G' * n)
	else:
		print('NO')
elif k == 1:
	if g > b:
		if g - b == 1:
			tea += 'GB' * (n // 2)
			tea += 'G'
			print(tea)
		else:
			print('NO')
	elif g < b:
		if b - g == 1:
			tea += 'BG' * (n // 2)
			tea += 'B'
			print(tea)
		else:
			print('NO')
	else:
		tea += 'GB' * (n // 2)
		print(tea)
elif g > b:
	steps = (g - b) // (k - 1)
	if steps > b + 1:
		if k == 2:
			big_left = g - b * 2
			if big_left > 2:
				print('NO')
				state = False
			else:
				state = True
				steps = b
		else:
			print('NO')
			state = False
	else:
		state = True
	if state:
		tea += 'G' * k
		tea += 'B'
		if steps == b + 1:
			steps -= 1
			tea *= steps
			g -= k * steps
			b -= steps
		else:
			tea *= steps
			g -= k * steps
			b -= steps
		diff = g - b
		if diff != 0 and g > 0 and (b > 0):
			diff += 1
			tea += 'G' * diff
			g -= diff
			tea += 'B'
			b -= 1
		if b == 0:
			rem = 'G' * g
		else:
			rem = 'GB' * g
		tea += rem
		print(tea)
else:
	steps = (b - g) // (k - 1)
	if steps > g + 1:
		if k == 2:
			big_left = b - g * 2
			if big_left > 2:
				print('NO')
				state = False
			else:
				state = True
				steps = g
		else:
			print('NO')
			state = False
	else:
		state = True
	if state:
		tea += 'B' * k
		tea += 'G'
		if steps == g + 1:
			steps -= 1
			tea *= steps
			b -= k * steps
			g -= steps
		else:
			tea *= steps
			b -= k * steps
			g -= steps
		diff = b - g
		if diff != 0 and g > 0 and (b > 0):
			diff += 1
			tea += 'B' * diff
			b -= diff
			tea += 'G'
			g -= 1
		if g == 0:
			rem = 'B' * b
		else:
			rem = 'GB' * b
		tea += rem
		print(tea)


(n, k, a, b) = list(map(int, input().split()))
ans = ''
if a > b:
	if a / (b + 1) > k:
		print('NO')
	else:
		left = a % (b + 1)
		m = a // (b + 1)
		ans = list('G' * n)
		count = 0
		pos = 0
		for i in range(b):
			if left != 0:
				pos += m + 1
				ans[pos + i] = 'B'
				left -= 1
			else:
				pos += m
				ans[pos + i] = 'B'
		print(''.join(ans))
if a == b:
	for i in range(a):
		ans += 'GB'
	print(ans)
if a < b:
	if b / (a + 1) > k:
		print('NO')
	else:
		left = b % (a + 1)
		m = b // (a + 1)
		ans = list('B' * n)
		count = 0
		pos = 0
		for i in range(a):
			if left != 0:
				pos += m + 1
				ans[pos + i] = 'G'
				left -= 1
			else:
				pos += m
				ans[pos + i] = 'G'
		print(''.join(ans))


(n, k, a, b) = map(int, input().split())
d = {a: 'G', b: 'B'}
if a < b:
	(a, b) = (b, a)
if k < (a + b) // (b + 1):
	print('NO')
	exit()
if a == b:
	print('GB' * a)
	exit()
print(((d[a] * ((a + b) // (b + 1)) + d[b]) * (a % (b + 1)) + (d[a] * (a // (b + 1)) + d[b]) * [-a % (b + 1), b + 1][-a % (b + 1) == 0])[:-1])


(n, k, a, b) = [int(x) for x in input().strip().split(' ')]
if a > b:
	parity = 1
else:
	parity = 0
st = ''
while a > 0 and b > 0:
	if parity:
		if a > b:
			st += 'G' * min(k, a - b)
			a -= min(k, a - b)
		else:
			st += 'G'
			a -= 1
		parity = 0
	else:
		if b > a:
			st += 'B' * min(k, b - a)
			b -= min(k, b - a)
		else:
			st += 'B'
			b -= 1
		parity = 1
if max(a, b) > k:
	print('NO')
else:
	if a > 0:
		st += 'G' * a
	elif b > 0:
		st += 'B' * b
	print(st)


import sys
input = sys.stdin.readline
l = input().split()
n = int(l[0])
k = int(l[1])
a = int(l[2])
b = int(l[3])
z = min(a, b)
if z < n // (k + 1):
	print('NO')
	quit()
lasta = 0
lastb = 0
for i in range(n):
	if a >= b:
		if lasta == k:
			print('B', end='')
			b -= 1
			lastb += 1
			lasta = 0
		else:
			print('G', end='')
			a -= 1
			lasta += 1
			lastb = 0
	elif lastb == k:
		print('G', end='')
		a -= 1
		lastb = 0
		lasta += 1
	else:
		print('B', end='')
		b -= 1
		lastb += 1
		lasta = 0


(n, k, a, b) = map(int, input().split())
if a == 0:
	if b <= k:
		ans = ['B'] * b
		print(''.join(ans))
		exit(0)
	else:
		print('NO')
		exit(0)
if b == 0:
	if a <= k:
		ans = ['G'] * a
		print(''.join(ans))
		exit(0)
	else:
		print('NO')
		exit(0)
sa = 'G'
sb = 'B'
if a > b:
	(a, b) = (b, a)
	(sa, sb) = (sb, sa)
from math import ceil
x = ceil(b / (a + 1))
if x > k:
	print('NO')
	exit(0)
x = b // (a + 1)
ans = []
cnta = 0
cntb = 0
z = b % (a + 1)
for i in range(a + 1):
	X = x
	if z:
		X = x + 1
		z -= 1
	for j in range(X):
		if cntb == b:
			break
		ans.append(sb)
		cntb += 1
	if i != a:
		ans.append(sa)
	cnta += 1
cnt = [0] * n
cnt[0] = 1
for i in range(1, n):
	if ans[i] == ans[i - 1]:
		cnt[i] = 1 + cnt[i - 1]
	else:
		cnt[i] = 1
	if cnt[i] > k:
		print('NO')
		exit(0)
print(''.join(ans))


import math

def solve(n, k, a, b):
	(m, r) = (n // (k + 1), n % (k + 1))
	if min(a, b) < m:
		return None
	a -= m
	b -= m
	if b >= r:
		d = 'GB'
		head = 'B' * r
		b -= r
	else:
		d = 'BG'
		head = 'B' * b + 'G' * (r - b)
		a -= r - b
		b = 0
	if k == 1:
		return head + d * m
	(a1, a2) = (a // (k - 1), a % (k - 1))
	(b1, b2) = (b // (k - 1), b % (k - 1))
	block1 = d + 'G' * (k - 1)
	block2 = d + 'B' * (k - 1)
	block3 = d + 'G' * a2 + 'B' * b2 if a2 > 0 or b2 > 0 else ''
	return head + block1 * a1 + block3 + block2 * b1
(n, k, a, b) = map(int, input().split())
s = solve(n, k, a, b)
print('NO' if s is None else s)


(n, k, a, b) = map(int, input().split())
n1 = n
if a + b < n:
	print('NO')
	exit()
res = ''
(imposa, imposb) = (False, False)
while n1 > 0 and a >= 0 and (b >= 0):
	if a > b:
		if imposa:
			if b <= 0:
				print('NO')
				exit()
			res += 'B'
			imposa = False
			b -= 1
			n1 -= 1
		else:
			if min(k, a - b) == k:
				imposa = True
			res += 'G' * min(k, a - b)
			n1 -= min(k, a - b)
			a -= min(k, a - b)
	elif b > a:
		if imposb:
			if a <= 0:
				print('NO')
				exit()
			res += 'G'
			imposb = False
			a -= 1
			n1 -= 1
		else:
			if min(k, b - a) == k:
				imposb = True
			res += 'B' * min(b - a, k)
			n1 -= min(k, b - a)
			b -= min(k, b - a)
	else:
		if res and res[-1] == 'B':
			res += 'GB' * (n1 // 2)
		elif res and res[-1] == 'G':
			res += 'BG' * (n1 // 2)
		else:
			res += 'GB' * (n1 // 2)
		n1 = 0
print(res)


def swap(c):
	if c == 'G':
		return 'B'
	else:
		return 'G'
(n, k, a, b) = map(int, input().split())
bchar = 'G' if a > b else 'B'
schar = swap(bchar)
(a, b) = (min(a, b), max(a, b))
res = []
while b > 0:
	t1 = min(b, k)
	t2 = k * a // b
	res.append(bchar * t1)
	b -= t1
	if a > 0:
		t2 = min(max(1, t2), a, t1)
		res.append(schar * t2)
		a -= t2
	elif b > 0:
		res = ['NO']
		break
print(''.join(res))


(n, k, a, b) = map(int, input().split())
kr1 = 'G'
kr2 = 'B'
if a < b:
	(a, b) = (b, a)
	kr1 = 'B'
	kr2 = 'G'
if (b + 1) * k < a:
	print('NO')
else:
	kol = a // k
	while kol > 0:
		print(kr1 * k, end='')
		a -= k
		z = b // kol
		if z == 0 and b != 0:
			z = 1
		if z != 0:
			print(kr2 * z, end='')
			b -= z
		kol -= 1
	if a > 0:
		print(kr1 * a, end='')
	if b > 0:
		print(kr2 * b)


from collections import Counter
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 sys
import sys
import math
(n, k, a, b) = map(int, input().split())
if float(max(a, b)) / (float(min(a, b)) + 1) > k:
	print('NO')
else:
	if a > b:
		w = 'GB'
	else:
		(a, b) = (b, a)
		w = 'BG'
	ans = ''
	c = int(math.floor(float(a) / float(b + 1)))
	for i in range(b + 1):
		d = 1 if i < a % (b + 1) else 0
		ans += w[0] * (c + d)
		if i != b:
			ans += w[1]
	print(ans)


def chered(s1, s2, n):
	ot = ''
	for k in range(n):
		if k % 2 == 0:
			ot = ot + s1
		else:
			ot = ot + s2
	return ot

def slicing(k, a, b):
	global portion_g
	global portion_b
	portion_g = []
	a_ost = a
	while a_ost > 0:
		if a_ost >= k:
			pg = 'G' * k
		else:
			pg = 'G' * a_ost
		portion_g.append(pg)
		a_ost -= k
	portion_b = []
	b_ost = b
	while b_ost > 0:
		if b_ost >= k:
			pg = 'B' * k
		else:
			pg = 'B' * b_ost
		portion_b.append(pg)
		b_ost -= k
	return None
(n, k, a, b) = [int(i) for i in input().split()]
if k == 1:
	if b <= a <= b + 1:
		slovo = chered('G', 'B', n)
		print(slovo)
	elif a <= b <= a + 1:
		slovo = chered('B', 'G', n)
		print(slovo)
	else:
		print('NO')
else:
	slicing(k, a, b)
	if len(portion_g) >= len(portion_b):
		while len(portion_g) > len(portion_b) + 1:
			isLong = False
			for k in range(len(portion_b)):
				if len(portion_b[k]) > 1:
					isLong = True
					portion_b[k] = portion_b[k][1:]
					portion_b.append('B')
					break
			if not isLong:
				break
		if len(portion_g) <= len(portion_b) + 1:
			co = []
			for k in range(len(portion_g)):
				co.append(portion_g[k])
				if k < len(portion_b):
					co.append(portion_b[k])
			ot = ''.join(co)
			print(ot)
		else:
			print('NO')
	else:
		while len(portion_b) > len(portion_g) + 1:
			isLong = False
			for k in range(len(portion_g)):
				if len(portion_g[k]) > 1:
					isLong = True
					portion_g[k] = portion_g[k][1:]
					portion_g.append('G')
					break
			if not isLong:
				break
		if len(portion_b) <= len(portion_g) + 1:
			co = []
			for k in range(len(portion_b)):
				co.append(portion_b[k])
				if k < len(portion_g):
					co.append(portion_g[k])
			ot = ''.join(co)
			print(ot)
		else:
			print('NO')


(n, k, a, b) = (int(z) for z in input().split())
(x, y) = ('G', 'B')
if a < b:
	(a, b) = (b, a)
	(x, y) = (y, x)
ans = ''
if (b + 1) * k < a:
	print('NO')
else:
	(r, curr) = (0, x)
	for i in range(n):
		if a - b <= 1 and r < k:
			ssss = 0
			for j in range(i, n):
				if ssss % 2:
					ans += y
				else:
					ans += x
				ssss += 1
			break
		if r < k:
			ans += x
			r += 1
			a -= 1
		else:
			ans += y
			r = 0
			b -= 1
print(ans)


(n, k, a, b) = [int(i) for i in input().split()]
x = a
y = b
chk = -1
ans = ''
while len(ans) <= n:
	if x == y:
		if len(ans) and ans[-1] == 'G':
			ans += 'BG' * ((n + 1) // 2)
		else:
			ans += 'GB' * ((n + 1) // 2)
		break
	elif chk == 0 or (chk == -1 and x > y):
		t = min(k, max(1, x - y))
		ans += 'G' * t
		x -= t
		chk = 1
	elif chk == 1 or (chk == -1 and x < y):
		t = min(k, max(1, y - x))
		ans += 'B' * t
		y -= t
		chk = 0
ans = ans[:n]
print(ans if ans.count('G') == a and ans.count('B') == b else 'NO')


def ri():
	return map(int, input().split())
(n, k, a, b) = ri()
s = []
if a > b:
	while n > 0:
		if a > b:
			aa = min(k, a, a - b)
		else:
			aa = 1
		s.append('G' * aa)
		n -= aa
		a -= aa
		if n > 0:
			if b <= 0:
				print('NO')
				exit()
			s.append('B')
			n -= 1
			b -= 1
else:
	while n > 0:
		if a < b:
			bb = min(k, b, b - a)
		else:
			bb = 1
		s.append('B' * bb)
		n -= bb
		b -= bb
		if n > 0:
			if a <= 0:
				print('NO')
				exit()
			s.append('G')
			n -= 1
			a -= 1
print(''.join(s))


import math
(n, k, a, b) = list(map(int, input().split()))
s = ''
if math.ceil(max(a, b) / (min(a, b) + 1)) <= k:
	if a > b:
		s1 = 'G'
		s2 = 'B'
		x = a
		y = b
	else:
		s2 = 'G'
		s1 = 'B'
		x = b
		y = a
	num = 0
	for i in range(n):
		if num < k and x > y:
			print(s1, end='')
			num += 1
			x -= 1
		else:
			print(s2, end='')
			num = 0
			y -= 1
else:
	print('NO')


(n, k, g, b) = map(int, input().split())
s = ''
l = r = 0
for i in range(n):
	if g > b:
		if g != 0 and k > l:
			s += 'G'
			g -= 1
			l += 1
			r = 0
		elif b != 0 and k > r:
			s += 'B'
			b -= 1
			r += 1
			l = 0
		else:
			s = 'NO'
			break
	elif b != 0 and k > r:
		s += 'B'
		b -= 1
		r += 1
		l = 0
	elif g != 0 and k > l:
		s += 'G'
		g -= 1
		l += 1
		r = 0
	else:
		s = 'NO'
		break
print(s)


(n, k, a, b) = map(int, input().split())
ans = ''
mistake = False
while abs(a - b) > 0:
	if abs(a - b) > k:
		if a > b:
			a -= k
			if b - 1 < 0:
				mistake = True
				break
			b -= 1
			if ans == '' or ans[-1] == 'B':
				ans += 'G' * k
				ans += 'B'
			else:
				ans += 'B'
				ans += 'G' * k
		else:
			b -= k
			if a - 1 < 0:
				mistake = True
				break
			a -= 1
			if ans == '' or ans[-1] == 'G':
				ans += 'B' * k
				ans += 'G'
			else:
				ans += 'G'
				ans += 'B' * k
	elif a > b:
		x = a - b
		a -= x
		if ans != '' and ans[-1] == 'G':
			mistake = True
			break
		else:
			ans += 'G' * x
	else:
		x = b - a
		b -= x
		if ans == '' or ans[-1] == 'G':
			ans += 'B' * x
		else:
			mistake = True
			break
if ans == '' or ans[-1] == 'G':
	ans += 'BG' * a
else:
	ans += 'GB' * a
if not mistake and len(ans) == n:
	print(ans)
else:
	print('NO')


(n, k, a, b) = map(int, input().split())
a_min = (a + k - 1) // k
b_min = (b + k - 1) // k
if b_min <= a_min <= b + 1 or a_min <= b_min <= a + 1:
	while a > 0 or b > 0:
		if a - b >= k:
			print('G' * k, end='')
			print('B' * min(1, b), end='')
			a -= k
			b -= min(1, b)
		elif 0 < a - b < k:
			print('G' * (a - b), end='')
			print('B' * min(1, b), end='')
			a -= a - b
			b -= min(1, b)
		elif b - a >= k:
			print('B' * k, end='')
			print('G' * min(1, a), end='')
			b -= k
			a -= min(1, a)
		elif 0 < b - a < k:
			print('B' * (b - a), end='')
			print('G' * min(1, a), end='')
			b -= b - a
			a -= min(1, a)
		else:
			print('GB' * a, end='')
			b = 0
			a = 0
else:
	print('NO')


(n, k, a, b) = map(int, input().split())
order = []
if a == b:
	print('GB' * a)
elif a > b:
	val = 0
	for i in range(n):
		if a > b and val < k:
			a -= 1
			val += 1
			order.append('G')
		else:
			b -= 1
			val = 0
			order.append('B')
	if a == b:
		print(''.join(order))
	else:
		print('NO')
else:
	(a, b) = (b, a)
	val = 0
	for i in range(n):
		if a > b and val < k:
			a -= 1
			val += 1
			order.append('G')
		else:
			b -= 1
			val = 0
			order.append('B')
	if a == b:
		for i in order:
			if i == 'B':
				print('G', end='')
			else:
				print('B', end='')
		print('')
	else:
		print('NO')


(n, k, a, b) = [int(v) for v in input().split()]
G = 'G'
B = 'B'
if a > b:
	(a, b) = (b, a)
	(G, B) = (B, G)
ans = []
while b - a > 1 and a >= 1:
	take_b = min(k, b - a)
	ans.append(B * take_b)
	ans.append(G)
	b -= take_b
	a -= 1
assert a <= b
ans.append((B + G) * a)
b -= a
a = 0
if b > k:
	print('NO')
else:
	ans.append(B * b)
	s = ''.join(ans)
	assert len(s) == n
	print(s)