Overlooking the captivating blend of myriads of vernal hues, Arkady the painter lays out a long, long canvas.

Arkady has a sufficiently large amount of paint of three colours: cyan, magenta, and yellow. On the one-dimensional canvas split into n consecutive segments, each segment needs to be painted in one of the colours.

Arkady has already painted some (possibly none or all) segments and passes the paintbrush to you. You are to determine whether there are at least two ways of colouring all the unpainted segments so that no two adjacent segments are of the same colour. Two ways are considered different if and only if a segment is painted in different colours in them.


-----Input-----

The first line contains a single positive integer n (1 ≤ n ≤ 100) — the length of the canvas.

The second line contains a string s of n characters, the i-th of which is either 'C' (denoting a segment painted in cyan), 'M' (denoting one painted in magenta), 'Y' (one painted in yellow), or '?' (an unpainted one).


-----Output-----

If there are at least two different ways of painting, output "Yes"; otherwise output "No" (both without quotes).

You can print each character in any case (upper or lower).


-----Examples-----
Input
5
CY??Y

Output
Yes

Input
5
C?C?Y

Output
Yes

Input
5
?CYC?

Output
Yes

Input
5
C??MM

Output
No

Input
3
MMY

Output
No



-----Note-----

For the first example, there are exactly two different ways of colouring: CYCMY and CYMCY.

For the second example, there are also exactly two different ways of colouring: CMCMY and CYCMY.

For the third example, there are four ways of colouring: MCYCM, MCYCY, YCYCM, and YCYCY.

For the fourth example, no matter how the unpainted segments are coloured, the existing magenta segments will prevent the painting from satisfying the requirements. The similar is true for the fifth example.

Source: codeforces | Difficulty: EASY
Tags: Implementation


Solutions:
n = int(input())
t = input()
b = True
for i in range(len(t) - 1):
	if t[i] == t[i + 1] and t[i] != '?':
		b = False
		break
if not b:
	print('No')
else:
	b = False
	if t[0] == '?' or t[len(t) - 1] == '?':
		b = True
	for i in range(1, len(t) - 1):
		if t[i] == '?' and (t[i - 1] == t[i + 1] or t[i - 1] == '?' or t[i + 1] == '?'):
			b = True
	if b:
		print('Yes')
	else:
		print('No')


def test_3():
	from collections import Counter
	n = list(map(int, input().split(' ')))[0]
	data = list(input())
	a = 0
	for i in range(len(data)):
		if data[i] != '?':
			if i != n - 1 and data[i] == data[i + 1]:
				print('No')
				return 0
		elif i in (0, n - 1) or data[i + 1] == '?' or data[i - 1] == '?' or (data[i - 1] != '?' and data[i + 1] != '?' and (data[i - 1] == data[i + 1])):
			a = 1
	if a == 1:
		print('Yes')
	else:
		print('No')
test_3()


def findq(s, i):
	start = s.find('?', i)
	if start != -1:
		stop = start
		while stop < len(s) and s[stop] == '?':
			stop += 1
		return (start, stop - start)
	else:
		return (None, None)

def main():
	n = int(input())
	s = input()
	no = False
	for x in 'CMY':
		if x * 2 in s:
			no = True
	if no:
		print('No')
		return
	else:
		two_ways = False
		(i, l) = findq(s, 0)
		while i is not None:
			if l == 1 and 0 <= i - 1 and (i + l < n) and (s[i - 1] != s[i + l]):
				pass
			else:
				two_ways = True
				break
			(i, l) = findq(s, i + l)
		if two_ways:
			print('Yes')
		else:
			print('No')
main()


input()
s = input()
if 'MM' in s or 'CC' in s or 'YY' in s:
	print('No')
elif '??' in s or s[0] == '?' or s[-1] == '?' or ('C?C' in s) or ('Y?Y' in s) or ('M?M' in s):
	print('Yes')
else:
	print('No')


count = int(input())
count_variable = 1
colours = input()
answer = 'Yes'
colour = colours[0]
if colour == '?':
	count_variable += 1
for i in range(1, count):
	if colours[i] == colour and colour != '?':
		answer = 'No'
	if colours[i] == '?':
		if i == count - 1:
			count_variable += 1
		elif colours[i - 1] == colours[i + 1] or colours[i - 1] == '?' or colours[i + 1] == '?':
			count_variable += 1
	colour = colours[i]
if count_variable == 1:
	answer = 'No'
print(answer)


def main():
	N = int(input())
	S = input()
	if any(('CC' in S, 'MM' in S, 'YY' in S, '?' not in S)):
		ans = 'No'
	elif S[0] == '?' or S[-1] == '?':
		ans = 'Yes'
	else:
		for i in range(1, N - 1):
			if S[i] == '?':
				if S[i - 1] != S[i + 1] != '?':
					ans = 'No'
				else:
					ans = 'Yes'
					break
	print(ans)
main()


n = int(input())
a = input()
for i in range(n - 1):
	if a[i] == a[i + 1] != '?':
		print('No')
		exit(0)
if '?' not in a:
	print('No')
	exit(0)
if '??' in a:
	print('Yes')
	exit(0)
for i in range(1, n - 1):
	if a[i] == '?' and a[i - 1] != '?' and (a[i - 1] == a[i + 1]) and (a[i + 1] != '?'):
		print('Yes')
		exit(0)
if '?' in a[0] + a[-1]:
	print('Yes')
else:
	print('No')


n = int(input())
s = input()
cl = ['M', 'C', 'Y']
res = True
count = s.count('?')
for i in range(1, n - 1):
	if s[i] != '?' and s[i - 1] != '?' and (s[i - 1] == s[i]) or (s[i] != '?' and s[i + 1] != '?' and (s[i] == s[i + 1])):
		res = False
		break
	if s[i - 1] != '?' and s[i + 1] != '?' and (s[i - 1] != s[i + 1]) and (s[i] == '?'):
		count -= 1
if count == 0:
	res = False
if res:
	print('Yes')
else:
	print('No')


import math
import queue
from itertools import permutations
n = int(input())
s = input()

def determine(t):
	for i in range(0, n - 1):
		if t[i] == t[i + 1] and t[i] != '?':
			return False
	for i in range(0, n - 1):
		if t[i] == '?' and t[i + 1] == '?':
			return True
	num = 0
	if t[0] == '?' or t[n - 1] == '?':
		return True
	for i in range(1, n - 1):
		if t[i] == '?' and t[i - 1] == t[i + 1]:
			return True
	return False
if determine(s):
	print('YES')
else:
	print('No')


def two_ways(s):
	already_spoiled = False
	more_than_one_way = False
	ind = 0
	row_counter = 0
	while ind < len(s) and (not already_spoiled):
		if s[ind] == '?':
			row_counter += 1
		elif ind > 0:
			prev = s[ind - row_counter - 1]
			if ind - row_counter - 1 < 0:
				prev = s[ind]
			if row_counter == 0 and prev == s[ind]:
				already_spoiled = True
			elif row_counter == 1 and prev == s[ind] or row_counter > 1:
				more_than_one_way = True
			row_counter = 0
		ind += 1
	if row_counter != 0:
		return True
	return not already_spoiled and more_than_one_way
n = int(input())
s = input()
if two_ways(s):
	print('Yes')
else:
	print('No')


import sys
n = int(input().strip())
s = input().strip()
ans = False
if s[0] == '?' or s[n - 1] == '?':
	ans = True
for i in range(1, n - 1):
	if s[i] == '?':
		if s[i - 1] == '?' or s[i + 1] == '?':
			ans = True
			break
		if s[i - 1] == s[i + 1]:
			ans = True
			break
if ans:
	for i in range(1, n):
		if s[i - 1] == s[i] and s[i] != '?':
			ans = False
			break
if ans:
	print('Yes')
else:
	print('No')


(n, s) = (input(), input())
print('Yes' if ('??' in s or 'C?C' in s or 'Y?Y' in s or ('M?M' in s) or (s[0] == '?') or (s[-1] == '?')) and (not ('CC' in s or 'MM' in s or 'YY' in s)) else 'No')


n = input()
s = input()
any_in = lambda p, s: any((x in s for x in p.split()))
if any_in('CC YY MM', s):
	print('No')
elif any_in('?? C?C M?M Y?Y', '?' + s + '?'):
	print('Yes')
else:
	print('No')


import sys

def p(s):
	print(s)
	sys.exit(0)
n = int(input())
s = input()
if 'CC' in s or 'YY' in s or 'MM' in s:
	p('No')
if s[0] == '?' or s[-1] == '?':
	p('Yes')
if '??' in s:
	p('Yes')
if 'C?C' in s or 'Y?Y' in s or 'M?M' in s:
	p('Yes')
p('No')


t = int(input())
str = input()
if 'MM' in str or 'YY' in str or 'CC' in str:
	print('No')
elif '??' in str or str[0] == '?' or str[-1] == '?' or ('M?M' in str) or ('Y?Y' in str) or ('C?C' in str):
	print('Yes')
else:
	print('No')


import re
f = re.search
x = input()
s = input()
if f('CC|MM|YY', s) or not f('^\\?|\\?\\?|\\?$|(C|M|Y)\\?\\1', s):
	print('NO')
else:
	print('YES')


n = int(input())
s = input()
n = len(s)
dp = [[0, 0, 0] for _ in range(n)]
if s[0] == 'C':
	dp[0][0] = 1
if s[0] == 'M':
	dp[0][1] = 1
if s[0] == 'Y':
	dp[0][2] = 1
if s[0] == '?':
	dp[0][0] = 1
	dp[0][1] = 1
	dp[0][2] = 1
for (i, c) in enumerate(s[1:]):
	if c == 'C':
		dp[i + 1][0] += dp[i][1] + dp[i][2]
	if c == 'M':
		dp[i + 1][1] += dp[i][0] + dp[i][2]
	if c == 'Y':
		dp[i + 1][2] += dp[i][0] + dp[i][1]
	if c == '?':
		dp[i + 1][0] += dp[i][1] + dp[i][2]
		dp[i + 1][1] += dp[i][0] + dp[i][2]
		dp[i + 1][2] += dp[i][0] + dp[i][1]
if sum(dp[-1]) > 1:
	print('Yes')
else:
	print('No')


import os
import sys
from io import BytesIO, IOBase
from itertools import groupby

def main():
	n = int(input())
	s = input()
	a = [[x, len(list(y))] for (x, y) in groupby(s)]
	l = ['C', 'M', 'Y']
	chk = 1
	for x in range(len(a)):
		if a[x][1] > 1 and a[x][0] == '?':
			chk = 0
			continue
		if a[x][1] == 1 and a[x][0] == '?':
			if x != len(a) - 1 and x != 0:
				if a[x - 1][0] == a[x + 1][0]:
					chk = 0
					continue
			elif a[x][0] == '?':
				chk = 0
	for x in range(len(a)):
		if a[x][1] >= 2 and a[x][0] in l:
			chk = 1
			break
	if chk == 1 or '?' not in s:
		print('NO')
	else:
		print('YES')
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 = int(input())
s = '?' + input() + '?'
flag = False
for x in range(1, len(s) - 1):
	if s[x] == '?':
		k = 0
		for y in ['C', 'Y', 'M']:
			if s[x - 1] != y and s[x + 1] != y:
				k += 1
		if k > 1:
			flag = True
	elif s[x - 1] == s[x] or s[x + 1] == s[x]:
		flag = False
		break
if flag:
	print('Yes')
else:
	print('No')


n = int(input())
s = input()
ans = 0
for i in range(1, n):
	if s[i - 1] == s[i] and s[i] != '?':
		ans = -1
		break
if ans == -1:
	print('No')
else:
	ans = 1
	for i in range(n):
		if s[i] == '?':
			if i - 1 >= 0 and i + 1 < n:
				if s[i - 1] == 'C' and s[i + 1] == 'Y' or (s[i - 1] == 'Y' and s[i + 1] == 'C') or (s[i - 1] == 'Y' and s[i + 1] == 'M') or (s[i - 1] == 'M' and s[i + 1] == 'Y') or (s[i - 1] == 'M' and s[i + 1] == 'C') or (s[i - 1] == 'C' and s[i + 1] == 'M'):
					ans = ans * 1
				else:
					ans = ans * 2
			else:
				ans = ans * 2
	if ans > 1:
		print('Yes')
	else:
		print('No')


n = int(input())
s = str(input())
flag = 0
for i in range(0, len(s) - 1):
	if s[i] == s[i + 1] and s[i] != '?':
		flag = 1
if flag == 1:
	print('NO')
elif flag == 0:
	if s[0] == '?' or s[-1] == '?':
		print('YES')
	else:
		flags = 0
		for j in range(0, len(s)):
			if s[j] == '?':
				d = set()
				if s[j + 1] != '?':
					d.add(s[j + 1])
				if s[j - 1] != '?':
					d.add(s[j - 1])
				if len(d) == 1:
					print('YES')
					flags = 1
					break
		if flags == 0:
			print('NO')


n = int(input())
s = list(input().strip())
for i in range(1, n):
	if s[i] != '?' and s[i - 1] != '?' and (s[i] == s[i - 1]):
		print('No')
		exit(0)
ok = False if s[0] != '?' and s[n - 1] != '?' else True
p = 1
while p + 1 < n:
	while p + 1 < n and s[p] != '?':
		p += 1
	q = p
	while q + 1 < n and s[q] == '?':
		q += 1
	l = q - p
	if l > 1:
		ok = True
	elif q + 1 < n and s[p - 1] == s[q]:
		ok = True
	p = q
if ok:
	print('Yes')
else:
	print('No')


n = int(input())
a = list(input()) + ['?']
f = False
for i in range(1, n):
	if a[i] == a[i - 1] and a[i] != '?':
		f = True
		break
if f:
	print('No')
	return
for i in range(n):
	if a[i] == '?':
		if a[i - 1] == a[i + 1] or a[i - 1] == '?' or a[i + 1] == '?':
			print('Yes')
			return
print('No')


a = int(input())
str1 = input()
if a == 1 and a == '?':
	print('Yes')
	exit(0)
pre = str1[0]
for x in range(1, a):
	if str1[x] == pre and str1[x] != '?':
		print('No')
		exit(0)
	pre = str1[x]
if str1[0] == '?' or str1[-1] == '?':
	print('Yes')
	exit(0)
pre = str1[0]
for x in range(1, a):
	if str1[x] == pre and str1[x] == '?':
		print('Yes')
		exit(0)
	pre = str1[x]
for x in range(1, a - 1):
	if str1[x] == '?' and str1[x - 1] == str1[x + 1]:
		print('Yes')
		exit(0)
print('No')


def f(s):
	for i in range(len(s) - 1):
		if s[i] != '?' and s[i] == s[i + 1]:
			return False
	if s[0] == '?' or s[-1] == '?':
		return True
	for i in range(len(s) - 1):
		if s[i + 1] == s[i] == '?':
			return True
	for i in range(1, len(s) - 1):
		if s[i] == '?' and s[i - 1] == s[i + 1]:
			return True
	return False
input()
s = input()
if f(s):
	print('Yes')
else:
	print('No')


n = int(input())
s = input()
ans = n
for i in range(0, n - 1):
	if s[i] == s[i + 1] and s[i] != '?':
		print('NO')
		raise SystemExit
if s[0] == '?' or s[n - 1] == '?':
	print('YES')
	raise SystemExit
a = []
b = []
for i in range(0, n - 1):
	if s[i] == '?':
		b.append(i)
	elif len(b) > 0:
		a.append(b)
		b = []
if len(b) > 0:
	a.append(b)
for i in range(0, len(a)):
	if len(a[i]) == 1 and s[a[i][0] - 1] == s[a[i][0] + 1] or len(a[i]) > 1:
		print('YES')
		raise SystemExit
print('NO')


num = int(input())
cs = input()
flag = False
breakflag = False
if 'CC' in cs or 'YY' in cs or 'MM' in cs:
	breakflag = True
if not breakflag and '??' in cs:
	flag = True
ps = cs.split('?')
if not flag and (not breakflag):
	for i in range(0, len(ps) - 1):
		if '' in set(ps):
			flag = True
			break
		if ps[i][-1] == ps[i + 1][0]:
			flag = True
			break
if flag:
	print('Yes')
else:
	print('No')


n = int(input())
s = input()
if n == 1:
	if s == '?':
		print('yes')
	else:
		print('no')
	quit()
for i in range(1, n):
	if s[i] == s[i - 1] and s[i] != '?':
		print('no')
		quit()
if s[0] == '?':
	print('yes')
	quit()
for i in range(1, n):
	if s[i] == '?':
		if i == n - 1 or s[i - 1] == s[i + 1] or s[i - 1] == '?' or (s[i + 1] == '?'):
			print('yes')
			quit()
print('no')


n = int(input())
s = input()
if 'MM' in s or 'CC' in s or 'YY' in s:
	print('NO')
elif s[0] == '?' or s[-1] == '?':
	print('YES')
else:
	for i in range(1, n - 1):
		if s[i] == '?':
			if s[i - 1] != '?' and s[i + 1] != '?':
				if s[i - 1] == s[i + 1]:
					print('YES')
					exit()
			else:
				print('YES')
				exit()
	print('NO')


def checker(paints: str) -> bool:
	limit = len(paints) - 1
	i = 1
	while i < limit:
		if paints[i] == '?' and paints[i - 1] != '?' and (paints[i + 1] != '?') and (paints[i - 1] != paints[i + 1]):
			paints = paints[:i] + paints[i + 1:]
			limit -= 1
		i += 1
	for i in range(0, len(paints) - 1):
		if paints[i] == paints[i + 1] and paints[i] != '?' and (paints[i + 1] != '?'):
			return False
	return '?' in paints
lengthOfTheCanvas = int(input())
paints1 = input()
if checker(paints1):
	print('Yes')
else:
	print('No')


n = int(input())
s = input()
val = ['??', 'C?C', 'M?M', 'Y?Y']
for i in ['CC', 'MM', 'YY']:
	if i in s:
		s = 'No'
if '?' not in s:
	s = 'No'
for i in val:
	if i in s or s == '?':
		s = 'Yes'
		break
if s[:2] in ['?C', '?Y', '?M']:
	s = 'Yes'
if s[-2:] in ['C?', 'Y?', 'M?']:
	s = 'Yes'
if s == 'Yes':
	print(s)
else:
	print('No')


import copy
n = int(input())
s = input()
ok = False
last = [s[0]]
colors = ['C', 'Y', 'M']
if n <= 2 and '?' in s:
	print('Yes')
else:
	mmax = 0
	if s[0] == '?' or s[-1] == '?':
		mmax = 2
	for i in range(1, n - 1):
		if s[i] == '?':
			if s[i - 1] == '?' or s[i + 1] == '?' or s[i - 1] == s[i + 1]:
				mmax = 2
		elif s[i] == s[i - 1] or s[i] == s[i + 1]:
			mmax = 0
			break
	if mmax == 2:
		print('Yes')
	else:
		print('No')


import sys

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

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

def Num():
	return int(input())
n = Num()
s = input()
is_cons = False
for i in range(1, n):
	if s[i] != '?' and s[i] == s[i - 1]:
		is_cons = True
if is_cons:
	print('NO')
else:
	(array, ch) = ([], ['Y', 'C', 'M'])
	if n == 1:
		if s in ch:
			print('NO')
		else:
			print('YES')
	elif n == 2:
		if s.count('?'):
			print('YES')
		else:
			print('NO')
	else:
		if s[0] == '?':
			array.append(2)
		elif s[n - 1] == '?':
			array.append(2)
		else:
			for i in range(1, n - 1):
				if s[i] == '?':
					if s[i - 1] in ch and s[i + 1] in ch:
						if s[i - 1] != s[i + 1]:
							array.append(1)
						else:
							array.append(2)
					else:
						array.append(2)
		ans = 1
		for i in array:
			ans *= i
		print('YES' if ans >= 2 else 'NO')


a = int(input())
l = input()
t = 1
for i in range(len(l) - 1):
	if l[i] == l[i + 1] and l[i] != '?':
		t = 0
		break
if t == 1:
	t = 0
	for i in range(len(l)):
		if l[i] == '?':
			if i == 0 or i == len(l) - 1:
				t = 1
				break
			else:
				if l[i - 1] == l[i + 1]:
					t = 1
					break
				if l[i + 1] == '?':
					t = 1
					break
		else:
			continue
if t == 1:
	print('Yes')
else:
	print('No')


n = int(input())
s = input()
for i in range(1, n):
	if s[i - 1] == s[i] and s[i] != '?':
		print('No')
		return
for i in range(1, n):
	if s[i - 1] == '?' and s[i] == '?':
		print('Yes')
		return
for i in range(1, n - 1):
	if s[i - 1] == s[i + 1] and s[i] == '?':
		print('Yes')
		return
if s[0] == '?' or s[-1] == '?':
	print('Yes')
else:
	print('No')


cc = int(input())
dd = input()
flag = 0
for i in range(1, cc):
	if dd[i] != '?' and dd[i] == dd[i - 1]:
		print('No')
		flag = 1
		break
if flag == 0:
	if dd[0] == '?':
		print('Yes')
	elif dd[cc - 1] == '?':
		print('Yes')
	else:
		count = 1
		flag = 1
		for i in range(0, cc):
			if dd[i] == '?':
				if dd[i + 1] == '?':
					print('Yes')
					flag = 0
					break
				elif dd[i - 1] == dd[i + 1]:
					print('Yes')
					flag = 0
					break
		if flag == 1:
			print('No')


n = int(input())
s = input()
for i in range(len(s) - 1):
	if s[i] != '?' and s[i] == s[i + 1]:
		print('NO')
		quit()
if s[0] == '?' or s[-1] == '?':
	print('YES')
	quit()
for i in range(1, len(s) - 1):
	if s[i] == '?':
		if s[i + 1] == '?' or s[i - 1] == '?' or s[i + 1] == s[i - 1]:
			print('YES')
			quit()
print('NO')


n = int(input())
s = input().rstrip()
notpaint = []
flg = True
for i in range(n):
	if i < n - 1 and s[i] != '?':
		if s[i] == s[i + 1]:
			flg = False
			break
	if s[i] == '?':
		notpaint.append(i)
if flg:
	work = 1
	for q in notpaint:
		if 0 == q or n - 1 == q:
			work *= 2
		elif s[q - 1] == s[q + 1] or s[q - 1] == '?' or s[q + 1] == '?':
			work *= 2
	if work > 1:
		print('Yes')
	else:
		print('No')
else:
	print('No')


input()
s = input()
if 'MM' in s or 'CC' in s or 'YY' in s or ('?' not in s):
	print('No')
	exit()
t = s.count('C?Y') + s.count('C?M') + s.count('Y?M')
t += s.count('Y?C') + s.count('M?Y') + s.count('M?C')
if t == s.count('?'):
	print('No')
	exit()
print('Yes')


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

def check(n, a):
	for i in range(n - 1):
		if a[i] == a[i + 1] and a[i] != '?':
			return False
	return True
l = []
c = 0
for i in range(n):
	if a[i] == '?':
		c = c + 1
	l.append(a[i])
k = 0
for i in range(n - 2):
	if a[i + 1] == '?' and a[i] == a[i + 2]:
		k = 1
if check(n, l) == False:
	print('No')
	k = 2

def main(l, n):
	t = []
	for i in l:
		b = i.index('?')
		q = []
		r = []
		s = []
		for j in range(b):
			q.append(i[j])
			r.append(i[j])
			s.append(i[j])
		q.append('Y')
		r.append('C')
		s.append('M')
		if 1 == 1:
			for j in range(b + 1, n):
				q.append(i[j])
				r.append(i[j])
				s.append(i[j])
		if check(n, q) == True:
			t.append(q)
		if check(n, r) == True:
			t.append(r)
		if check(n, s) == True:
			t.append(s)
	return t
if k == 1:
	print('Yes')
if k == 0:
	l = [l]
	for i in range(c):
		l = main(l, n)
	d = 0
	for i in l:
		if check(n, i) == True:
			if d == 1:
				print('Yes')
			d = d + 1
	if d == 0 or d == 1:
		print('No')


n = int(input())
str = input()
for i in range(len(str) - 1):
	if str[i] == str[i + 1] and str[i] != '?':
		print('No')
		exit(0)
if str[0] == '?' or str[-1] == '?' or '??' in str or ('M?M' in str) or ('C?C' in str) or ('Y?Y' in str):
	print('Yes')
else:
	print('No')


import sys
from functools import wraps

def memoize(function):
	memo = {}

	@wraps(function)
	def wrapper(*args):
		if args in memo:
			return memo[args]
		else:
			res = function(*args)
			memo[args] = res
			return res
	return wrapper

@memoize
def count(canvas, pos, last):
	if pos == len(canvas):
		return 1
	res = 0
	for color in 'CYM':
		if not (color == last or (canvas[pos] != '?' and color != canvas[pos])):
			res += count(canvas, pos + 1, color)
	return res

def main(args):
	n = int(input())
	canvas = input()
	print('Yes' if count(canvas, 0, 'X') >= 2 else 'No')
sys.exit(main(sys.argv))


n = int(input())
s = input()
if n <= 2 and '?' in s:
	print('Yes')
else:
	mmax = 0
	if s[0] == '?' or s[-1] == '?':
		mmax = 2
	for i in range(1, n - 1):
		if s[i] == '?':
			if s[i - 1] == '?' or s[i + 1] == '?' or s[i - 1] == s[i + 1]:
				mmax = 2
		elif s[i] == s[i - 1] or s[i] == s[i + 1]:
			mmax = 0
			break
	if mmax == 2:
		print('Yes')
	else:
		print('No')


n = int(input())
s = input()
j = s.count('?')
c = 0
for i in range(0, len(s) - 1):
	if s[i] == s[i + 1] and s[i] != '?':
		print('No')
		exit()
	if s[i] == '?':
		if s[i - 1] != s[i + 1] and s[i - 1] != '?' and (s[i + 1] != '?'):
			c += 1
if s[0] == '?' or s[n - 1] == '?':
	print('Yes')
	exit()
if c == j:
	print('No')
	exit()
print('Yes')


n = int(input())
Ar = input()
if Ar.find('MM') != -1:
	print('NO')
elif Ar.find('YY') != -1:
	print('NO')
elif Ar.find('CC') != -1:
	print('NO')
elif Ar[0] == '?' or Ar[-1] == '?':
	print('YES')
elif Ar.find('???') != -1:
	print('YES')
else:
	cnt = 0
	for i in range(1, n - 1):
		if Ar[i] == '?' and (Ar[i - 1] == 'C' and Ar[i + 1] == 'C' or (Ar[i - 1] == 'Y' and Ar[i + 1] == 'Y') or (Ar[i - 1] == 'M' and Ar[i + 1] == 'M')):
			cnt += 1
			break
	l = Ar.find('??')
	if l != -1:
		cnt += 1
	if cnt > 0:
		print('YES')
	else:
		print('NO')


n = int(input())
s = input()
s = '*' + s
s += '#'
yes = 0
if s[1] == '?' or s[n] == '?':
	yes = 1
for i in range(1, n + 2 - 1):
	if s[i] == '?':
		if (s[i - 1] != s[i + 1]) == False or s[i - 1] == '?' or s[i + 1] == '?':
			yes = 1
	elif s[i] == s[i - 1]:
		print('No')
		break
else:
	if yes:
		print('Yes')
	else:
		print('No')


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

def f():
	for i in range(n - 1):
		if s[i] == s[i + 1] and s[i] != '?':
			return False
	if '??' in s:
		return True
	if 'C?C' in s or 'M?M' in s or 'Y?Y' in s:
		return True
	if s[0] == '?' or s[n - 1] == '?':
		return True
	return False
if f():
	print('Yes')
else:
	print('No')


n = int(input())
s = input()
f = 1
for i in range(n - 1):
	if s[i] == s[i + 1] and s[i] != '?' and (s[i + 1] != '?'):
		f = 0
		break
if f == 0:
	print('No')
else:
	ms = set()
	if '??' in s:
		print('Yes')
	elif s[0] == '?' or s[-1] == '?':
		print('Yes')
	elif 'C?C' in s:
		print('Yes')
	elif 'M?M' in s:
		print('Yes')
	elif 'Y?Y' in s:
		print('Yes')
	else:
		print('No')


t = input()
a = list(input())
i = 0
maxm = 1
n = len(a)
while i < n:
	if a[i] == '?':
		if i == 0 or i == n - 1:
			maxm = 2
		elif i + 1 < n:
			if a[i + 1] == '?':
				maxm = 2
			elif i >= 1:
				if a[i + 1] == a[i - 1]:
					maxm = 2
	elif i < n - 1:
		if a[i] == a[i + 1]:
			maxm = 3
			break
	i = i + 1
if a[0] == '?' and n == 1:
	maxm = 2
if maxm == 2:
	print('Yes')
else:
	print('No')


def check(string):
	for i in range(len(string) - 1):
		if string[i] == string[i + 1] and string[i] != '?':
			return 0
	return 1

def cf(string, i):
	if i != len(string) - 1 and i:
		if string[i - 1] != string[i] and string[i] != string[i + 1]:
			return 1
	if not i:
		if string[0] != string[1]:
			return 1
	if i == len(string) - 1:
		if string[len(string) - 2] != string[len(string) - 1]:
			return 1
	return 0

def p(n):
	if n == 2:
		print('Yes')
		exit(0)
input()
canvas = input()
if canvas == '?' or canvas == '?M' or canvas == '?Y' or (canvas == '?C') or (canvas == 'M?') or (canvas == 'C?') or (canvas == 'Y?') or (canvas == '??'):
	print('Yes')
	exit(0)
count = 0
if not check(canvas) or len(canvas) < 3:
	print('No')
	exit(0)

def f(string):
	global count
	for i in range(len(string)):
		flag = 0
		if string[i] == '?':
			flag = 1
			par0 = string[:i] + 'C' + string[i + 1:]
			par1 = string[:i] + 'M' + string[i + 1:]
			par2 = string[:i] + 'Y' + string[i + 1:]
			if cf(par0, i):
				if '?' in par0:
					f(par0)
				else:
					count += 1
					p(count)
			if cf(par1, i):
				if '?' in par1:
					f(par1)
				else:
					count += 1
					p(count)
			if cf(par2, i):
				if '?' in par2:
					f(par2)
				else:
					count += 1
					p(count)
		if flag:
			break
f(canvas)
print('No')


import sys
n = int(sys.stdin.readline().strip())
s = sys.stdin.readline().strip()
if 'MM' in s or 'CC' in s or 'YY' in s:
	print('No')
elif s.startswith('?') or s.endswith('?') or '??' in s:
	print('Yes')
elif 'M?M' in s or 'Y?Y' in s or 'C?C' in s:
	print('Yes')
else:
	print('No')


lengthCanvas = int(input(''))
canvas = input('')
colors = ['C', 'M', 'Y']
flag = True
for i in range(len(canvas) - 1):
	if canvas[i] == canvas[i + 1] and canvas[i] != '?':
		flag = False
if flag:
	flag = False
	if canvas[0] == '?' or canvas[len(canvas) - 1] == '?':
		flag = True
	for i in range(len(canvas) - 1):
		if canvas[i] == '?' and canvas[i] == canvas[i + 1]:
			flag = True
	for i in range(1, len(canvas) - 1):
		if len(canvas) > 1 and canvas[i] == '?' and (canvas[i - 1] == canvas[i + 1]):
			flag = True
if flag:
	print('Yes')
else:
	print('No')


n = int(input())
s = input()
if s.find('CC') != -1 or s.find('YY') != -1 or s.find('MM') != -1:
	print('No')
elif s.find('??') != -1:
	print('Yes')
else:
	c = 0
	p = []
	f = 0
	for i in range(len(s)):
		if s[i] == '?':
			p.append(i)
	for y in p:
		if y == 0 or y == n - 1:
			print('Yes')
			f = 1
			break
		elif s[y - 1] == s[y + 1]:
			c += 2
			break
	if c >= 2 and f != 1:
		print('Yes')
	elif c < 2 and f != 1:
		print('No')


n = int(input())
string = input()
if string.find('MM') == -1 and string.find('CC') == -1 and (string.find('YY') == -1) and (string.find('?') != -1):
	if string[-1] == '?' or string[0] == '?' or string.find('C?C') != -1 or (string.find('M?M') != -1) or (string.find('Y?Y') != -1) or (string.find('??') != -1):
		print('Yes')
	else:
		print('No')
else:
	print('No')


input()
s = input()
if 'CC' in s or 'MM' in s or 'YY' in s:
	print('No')
elif '??' in s:
	print('Yes')
elif '?' not in s:
	print('No')
elif s.startswith('?') or s.endswith('?'):
	print('Yes')
else:
	for i in range(1, len(s) - 1):
		if s[i] == '?' and s[i - 1] == s[i + 1]:
			print('Yes')
			break
	else:
		print('No')


n = int(input())
arr = list(input())
cnt = 0

def dfs(idx):
	global cnt
	for i in range(len(arr) - 1):
		if arr[i] == arr[i + 1] and arr[i] != '?':
			return
	if idx == len(arr):
		cnt += 1
		if cnt == 2:
			print('Yes')
			exit(0)
		return
	if arr[idx] != '?':
		dfs(idx + 1)
	else:
		for c in ['C', 'M', 'Y']:
			arr[idx] = c
			dfs(idx + 1)
			arr[idx] = '?'
dfs(0)
print('No')


n = int(input())
s = input()
if 'YY' in s or 'CC' in s or 'MM' in s:
	print('No')
else:
	f = 0
	for i in range(n - 1):
		if s[i] == '?' and s[i + 1] == '?':
			f = 1
			break
		elif s[i] == '?':
			if i == 0 or s[i - 1] == s[i + 1]:
				f = 1
				break
	if s[-1] == '?':
		f = 1
	if f == 0:
		print('No')
	else:
		print('Yes')


n = int(input())
s = input()
a = 'No'
if s[0] == '?' or s[-1] == '?':
	a = 'Yes'
for i in range(1, n - 1):
	if s[i] == '?' and (not (s[i - 1] != s[i + 1] and s[i - 1] != '?' and (s[i + 1] != '?'))):
		a = 'Yes'
	if s[i] != '?' and s[i] == s[i - 1]:
		a = 'No'
		break
if n > 1 and s[-1] != '?' and (s[-1] == s[-2]):
	a = 'No'
print(a)


import re
f = re.search
input()
s = input()
print('No' if f('CC|MM|YY', s) or not f('^\\?|\\?\\?|\\?$|(C|M|Y)\\?\\1', s) else 'Yes')


arri = lambda : [int(s) for s in input().split()]
arrf = lambda : [float(s) for s in input().split()]
n = int(input())
s = input()
l = '?'
flag = True
for c in s:
	if l == c and c != '?':
		flag = False
	l = c
cnt = 0
for i in range(1, n - 1):
	if s[i] == '?' and s[i - 1] != '?' and (s[i + 1] != '?') and (s[i - 1] != s[i + 1]):
		cnt += 1
if cnt == s.count('?'):
	flag = False
print('Yes' if flag else 'No')


n = input()
s = input()

def say_no():
	print('No')
	exit(0)

def say_yes():
	print('Yes')
	exit(0)
for i in range(1, len(s)):
	if s[i] == s[i - 1] and s[i] != '?':
		say_no()
for i in range(1, len(s) - 1):
	if s[i] == '?' and (s[i - 1] == s[i + 1] or s[i - 1] == '?' or s[i + 1] == '?'):
		say_yes()
if s[0] == '?' or s[len(s) - 1] == '?':
	say_yes()
say_no()


n = int(input())
s = list(input())
colored = True
way2 = False
if s[0] == '?' or s[-1] == '?':
	way2 = True
for i in range(2, n):
	if s[i - 1] == '?' and s[i - 2] == s[i]:
		way2 = True
for i in range(1, n):
	if s[i] != '?' and s[i - 1] == s[i]:
		colored = False
	if s[i] == '?' and s[i - 1] == s[i]:
		way2 = True
if way2 and colored:
	print('Yes')
else:
	print('No')


n = int(input())
s = input()
ind = True
ind1 = False
y = []
for i in s:
	y.append(i)
for i in range(n):
	if y[i] == '?' and i == 0 or (y[i] == '?' and i == n - 1) or (y[i] == '?' and y[i - 1] == y[i + 1]) or ((y[i] == '?' and (y[i - 1] == '?' or y[i + 1])) == '?'):
		ind1 = True
	if i > 0 and (y[i] == y[i - 1] and y[i] != '?'):
		ind = False
		break
if ind and ind1:
	print('Yes')
else:
	print('No')


n = int(input())
canvas = input()
if any((x in canvas for x in ['CC', 'YY', 'MM'])):
	print('No')
elif canvas[0] == '?' or canvas[n - 1] == '?':
	print('Yes')
elif any((x in canvas for x in ['C?C', 'Y?Y', 'M?M', '??'])):
	print('Yes')
else:
	print('No')


import math
from decimal import Decimal

def na():
	n = int(input())
	b = [int(x) for x in input().split()]
	return (n, b)

def nab():
	n = int(input())
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	return (n, b, c)

def dv():
	(n, m) = map(int, input().split())
	return (n, m)

def dva():
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	return (n, m, b)

def eratosthenes(n):
	sieve = list(range(n + 1))
	for i in sieve:
		if i > 1:
			for j in range(i + i, len(sieve), i):
				sieve[j] = 0
	return sorted(set(sieve))

def nm():
	n = int(input())
	b = [int(x) for x in input().split()]
	m = int(input())
	c = [int(x) for x in input().split()]
	return (n, b, m, c)

def dvs():
	n = int(input())
	m = int(input())
	return (n, m)
n = int(input())
s = input()
k = 0
tk = 0
if n == 1 and s[0] == '?':
	print('YES')
	exit()
for i in range(n - 1):
	if s[i] == '?':
		k += 1
	if s[i] == '?' and i > 0 and (s[i - 1] != s[i + 1]) and (s[i - 1] != '?') and (s[i + 1] != '?'):
		tk += 1
	if s[i] == s[i + 1] and s[i] != '?':
		print('NO')
		exit()
if s[n - 1] == '?':
	k += 1
if k == tk:
	print('NO')
else:
	print('YES')


n = int(input())
s = input()
for i in range(n - 1):
	if s[i] == s[i + 1] and s[i] != '?':
		print('No')
		exit()
if s[0] == '?' or s[n - 1] == '?':
	print('Yes')
	exit()
for i in range(1, n - 1):
	if s[i] == '?':
		if s[i - 1] == '?' or s[i + 1] == '?':
			print('Yes')
			exit()
		elif s[i - 1] == s[i + 1]:
			print('Yes')
			exit()
print('No')


n = int(input())
s = input()
f = 0
f1 = 0
for i in range(len(s)):
	if s[i] == '?':
		if i == 0 or i == len(s) - 1 or (i != 0 and i != len(s) - 1 and (s[i - 1] == '?' or s[i + 1] == '?' or s[i - 1] == s[i + 1])):
			f = 1
	elif i != 0 and s[i - 1] == s[i]:
		f1 = 1
if f1:
	print('No')
elif f:
	print('Yes')
else:
	print('No')


import sys, math, os.path
import re
FILE_INPUT = 'A.in'
DEBUG = os.path.isfile(FILE_INPUT)
if DEBUG:
	sys.stdin = open(FILE_INPUT)

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

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

def log(x):
	if DEBUG:
		print(x)
n = ni()
s = input()
pattern = re.compile('[CYM]\\?[CYM]')
xx = ''
for x in s:
	if x == xx and x != '?':
		print('No')
		sys.exit()
	else:
		xx = x
if '??' in s or s[0] == '?' or s[-1] == '?':
	print('Yes')
	sys.exit()
else:
	for a in re.findall(pattern, s):
		if a[0] == a[-1]:
			print('Yes')
			sys.exit()
print('No')


def check(s):
	for i in range(1, n):
		if s[i] == s[i - 1] and s[i] != '?':
			return False
	return True
n = int(input())
s = input()
if not check(s):
	print('NO')
	exit()
ans = 'NO'
if s[0] == '?' or s[-1] == '?':
	print('YES')
	exit()
for i in range(n - 1):
	if s[i] == '?' and s[i + 1] == '?' or (i > 0 and s[i - 1] == s[i + 1] and (s[i] == '?')):
		ans = 'YES'
		break
print(ans)


n = int(input())
s = input()
f = False
for i in range(n):
	if s[i] == '?':
		if i == 0 or i == n - 1:
			f = True
			break
		if s[i + 1] == '?':
			f = True
			break
		if s[i - 1] == s[i + 1]:
			f = True
			break
for i in range(n - 1):
	if s[i] == s[i + 1] and s[i] != '?':
		f = False
		break
if f:
	print('Yes')
else:
	print('No')


n = int(input())
canvas = input()
unknown_status = False
if canvas[0] == '?' or canvas[-1] == '?':
	unknown_status = True
for i in range(1, n - 1):
	if canvas[i] == '?':
		if canvas[i + 1] == '?':
			unknown_status = True
			break
		elif canvas[i - 1] == canvas[i + 1]:
			unknown_status = True
			break
adjust_status = True
for i in range(n - 1):
	if canvas[i] == canvas[i + 1] and canvas[i] != '?':
		adjust_status = False
		break
print('Yes' if unknown_status and adjust_status else 'No')


n = int(input())
s = input()
flag = True
for i in range(0, n - 1):
	if s[i] == s[i + 1] and s[i] != '?':
		print('No')
		flag = False
		break
if flag:
	flag = False
	for i in range(0, n):
		if i < n - 1:
			if s[i] == s[i + 1] and s[i] == '?':
				flag = True
				break
		if i == 0:
			if s[i] == '?':
				flag = True
				break
		elif i == n - 1:
			if s[i] == '?':
				flag = True
				break
		elif s[i] == '?' and s[i - 1] == s[i + 1]:
			flag = True
			break
	if flag:
		print('Yes')
	else:
		print('No')


import sys
canvas_size = int(input())
canvas = input()
next_possibilities = 'CMY'
possible = False
if canvas[0] == '?' or canvas[-1] == '?':
	possible = True
for (i, color) in enumerate(canvas[1:len(canvas) - 1]):
	i += 1
	if color == '?':
		if canvas[i - 1] == '?' or canvas[i + 1] == '?' or canvas[i - 1] == canvas[i + 1]:
			possible = True
if not possible:
	print('No')
	sys.exit()
last_color = canvas[0]
for color in canvas[1:]:
	if color == last_color and color != '?':
		print('No')
		sys.exit()
	last_color = color
print('Yes')


import math
n = int(input())
s = input()
if '?' not in s:
	print('No')
else:
	f = 0
	c = 0
	for j in range(n - 1):
		if s[j] == s[j + 1] and s[j] != '?':
			print('No')
			f = 1
			break
		elif j > 0 and s[j] == '?' and (s[j - 1] != s[j + 1]) and (s[j - 1] != '?') and (s[j + 1] != '?'):
			c += 1
	if s.count('?') == c:
		print('No')
		f = 1
	if f == 0:
		print('Yes')


n = int(input())
s = input()
i = 1
ans = 1
if s[0] == '?':
	ans = 2
while i < n - 1:
	if s[i] != '?' and (s[i] == s[i + 1] or s[i] == s[i - 1]):
		print('No')
		exit()
	if s[i] == '?':
		if i <= n - 3 and s[i + 1] == '?':
			if s[i - 1] == s[i + 2]:
				ans *= 2
				i += 1
			elif s[i + 2] == '?':
				ans *= 2
			else:
				ans *= 4
		elif s[i - 1] == s[i + 1]:
			ans *= 2
	i += 1
if s[len(s) - 1] == '?':
	ans = 2
if ans > 1:
	print('Yes')
else:
	print('No')


N = int(input())
S = input()
if N == 1:
	if S == '?':
		print('Yes')
		quit()
	else:
		print('No')
		quit()
for i in range(N - 1):
	char1 = S[i]
	char2 = S[i + 1]
	if char1 == char2 and char1 != '?':
		print('No')
		quit()
if S.count('?') == 0:
	print('No')
	quit()
for i in range(N - 1):
	char1 = S[i]
	char2 = S[i + 1]
	if char1 == char2:
		print('Yes')
		quit()
if S[0] == '?' or S[N - 1] == '?':
	print('Yes')
	quit()
for i in range(1, N - 1):
	if S[i] == '?' and S[i - 1] == S[i + 1]:
		print('Yes')
		quit()
print('No')


from itertools import product

def get_input_list() -> str:
	canvas_lenght = input()
	canvas_caracters = input()
	return (canvas_lenght, canvas_caracters)

def get_input() -> str:
	raw_input_data = ''
	raw_input_data += input()
	return raw_input_data

def solve(raw_input_data: str):
	(chars, word) = raw_input_data
	chars = int(chars)
	yes = False
	if word[0] == '?' or word[-1] == '?':
		yes = True
	for i in range(1, chars):
		if word[i] != '?' and word[i] == word[i - 1]:
			return 'No'
		elif word[i] == '?':
			if i + 1 < chars and word[i - 1] == word[i + 1]:
				yes = True
			elif word[i - 1] == '?':
				yes = True
			elif i + 1 < chars and word[i + 1] == '?':
				yes = True
	if yes:
		return 'Yes'
	return 'No'
while True:
	try:
		input_data = get_input_list()
		answer = solve(input_data)
		print(answer, end='\n')
	except:
		break


n = int(input())
colors = [i for i in input()]
maners = []
if colors.count('?') == 0:
	print('No')
elif n == 1:
	print('Yes')
else:
	i = 0
	chave = True
	while i < n - 1:
		if colors[i] == colors[i + 1] and colors[i] != '?':
			chave = False
			break
		i += 1
	if chave:
		string = ''.join(colors)
		inter = 0
		inter += string.count('C?M')
		inter += string.count('C?Y')
		inter += string.count('Y?C')
		inter += string.count('Y?M')
		inter += string.count('M?C')
		inter += string.count('M?Y')
		if inter == string.count('?'):
			print('No')
		else:
			print('Yes')
	else:
		print('No')


n = int(input())
mural = input()
result = 'Yes'
flag = True
if mural.count('?') == 0:
	print('No')
elif n == 1 or n == 2:
	print('Yes')
else:
	flag2 = False
	for i in range(1, n - 1):
		if mural[i] == mural[i - 1] or mural[i] == mural[i + 1]:
			if mural[i] != '?':
				result = 'No'
				flag2 = True
				break
			else:
				result = 'Yes'
				flag = False
		elif mural[i] == '?' and flag:
			if mural[i - 1] != mural[i + 1]:
				result = 'No'
			else:
				result = 'Yes'
				flag = False
	if not flag2 and (mural[0] == '?' or mural[-1] == '?'):
		print('Yes')
	else:
		print(result)


n = input()
s = input()
if s.count('CC') or s.count('MM') or s.count('YY'):
	print('No')
elif s[0] == '?' or s[-1] == '?':
	print('Yes')
elif s.count('??'):
	print('Yes')
else:
	b = ''
	q = 0
	for i in s:
		if i != '?':
			if q > 0 and b == i:
				print('Yes')
				break
			q = 0
			b = i
		else:
			q += 1
	else:
		print('No')


i = input
i()
z = '?' + i() + '?'
print('Yes' if ('??' in z or 'Y?Y' in z or 'C?C' in z or ('M?M' in z)) and (not ('CC' in z or 'MM' in z or 'YY' in z)) else 'No')


n = int(input())
s = input()
x = False
dup = False
for i in range(0, n - 1):
	if s[i] == s[i + 1] and s[i] != '?':
		dup = True
		break
for i in range(0, n):
	if x:
		break
	if s[i] == '?':
		if i == 0:
			x = True
			continue
		elif i == n - 1:
			x = True
			continue
		else:
			a = s[i - 1]
			b = s[i + 1]
			if a == '?' or b == '?':
				x = True
				continue
			elif a == b:
				x = True
				continue
			else:
				continue
if dup:
	print('No')
elif x:
	print('Yes')
else:
	print('No')


x = int(input())
y = input()
for i in range(len(y) - 1):
	if y[i + 1] == y[i] and y[i] != '?':
		print('No')
		exit()
alist = []
for i in range(1, len(y) - 2):
	if y[i] == '?' and y[i - 1] != '?' and (y[i + 1] != '?'):
		alist.append(i)
	elif y[i] == '?' and y[i + 1] == '?':
		print('yes')
		exit()
if '?' in y:
	if y[0] == '?' or y[len(y) - 1] == '?':
		print('yes')
		exit()
	for i in alist:
		if y[i - 1] == y[i + 1]:
			continue
		else:
			print('No')
			exit()
	print('Yes')
else:
	print('No')


(_, x) = (input(), input())
if 'CC' in x or 'MM' in x or 'YY' in x:
	print('No')
elif x.count('?') == 0:
	print('No')
elif '??' in x:
	print('Yes')
elif x.count('?') - x.count('C?M') - x.count('C?Y') - x.count('M?Y') - x.count('M?C') - x.count('Y?C') - x.count('Y?M') == 0:
	print('No')
else:
	print('Yes')


n = int(input())
s = input()
for i in range(n - 1):
	if s[i] == s[i + 1] != '?':
		print('NO')
		break
else:
	for i in range(n):
		if s[i] == '?':
			if i != 0 and i != n - 1 and (s[i - 1] != s[i + 1]) and (s[i - 1] != '?') and (s[i + 1] != '?'):
				continue
			print('YES')
			break
	else:
		print('NO')


import sys, math
from collections import deque, defaultdict
import operator as op
from functools import reduce
from itertools import permutations
I = sys.stdin.readline

def ii():
	return int(I().strip())

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

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

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

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

def isPrime(n):
	if n <= 1:
		return False
	elif n <= 2:
		return True
	else:
		for i in range(2, int(n ** 0.5) + 1):
			if n % i == 0:
				return False
		return True

def main():
	n = ii()
	s = I().strip()
	if '?' not in s:
		print('No')
	else:
		flag = 1
		for i in range(1, n):
			if s[i] != '?' and s[i] == s[i - 1]:
				flag = 0
				break
		if flag == 1:
			flag = 0
			if s[0] == '?' or s[n - 1] == '?':
				flag = 1
			for i in range(1, n - 1):
				if s[i] == '?':
					if s[i - 1] == '?' or s[i + 1] == '?':
						flag = 1
						break
					elif s[i - 1] == s[i + 1]:
						flag = 1
						break
		if flag:
			print('Yes')
		else:
			print('No')
main()


def main():
	n = int(input())
	s = input().strip()
	ans = s[0] == '?' or s[-1] == '?'
	for i in range(1, n - 1):
		if s[i] != '?':
			continue
		l = s[i - 1]
		r = s[i + 1]
		if l == '?' or r == '?' or l == r:
			ans = True
			break
	for i in range(1, n):
		if s[i] != '?':
			ans = ans and s[i] != s[i - 1]
	if ans:
		print('Yes')
	else:
		print('No')
main()


from sys import stdin, stdout

def rint():
	return list(map(int, stdin.readline().split()))
n = int(input())
s = input()
s = ''.join(['?', s, '?'])
flag = 0
for i in range(1, n + 1):
	if s[i] is not '?':
		if s[i] is s[i - 1] or s[i] is s[i + 1]:
			print('No')
			return
	elif s[i - 1] is s[i + 1]:
		flag = 1
	elif s[i - 1] is '?' or s[i + 1] is '?':
		flag = 1
if flag:
	print('Yes')
else:
	print('No')


def result(n_color, segment):
	for i in range(0, n_color - 1):
		if segment[i] == segment[i + 1] and segment[i] != '?':
			return 'No'
	for i in range(0, n_color):
		if segment[i] == '?':
			if i == 0 or i == n_color - 1 or segment[i + 1] == '?' or (segment[i - 1] == segment[i + 1]):
				return 'Yes'
	return 'No'
print(result(int(input()), input()))


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

def colors(n, s):
	count = 1
	for i in range(n - 1):
		if s[i] == s[i + 1] and s[i] != '?':
			return 'No'
	for i in range(n):
		if s[i] == '?':
			if i == 0:
				count = 2
				return 'Yes'
			if i == n - 1:
				count = 2
				return 'Yes'
			if s[i - 1] == s[i + 1]:
				count = 2
				return 'Yes'
			if s[i + 1] == '?':
				return 'Yes'
	return 'No'
print(colors(n, s))


n = int(input())
s = input()
q = 0
for i in range(0, n):
	if i == 0 or i == n - 1:
		if s[i] == '?':
			q += 1
	elif s[i] != '?':
		if s[i] == s[i + 1] or s[i] == s[i - 1]:
			print('NO')
			exit()
	else:
		q += 1
if q == 0:
	print('NO')
	exit()
found = False
for i in range(n):
	if s[i] == '?':
		if i == 0 or i == n - 1:
			found = True
		elif s[i - 1] == '?' or s[i + 1] == '?':
			found = True
		elif s[i - 1] == s[i + 1]:
			found = True
if found:
	print('YES')
else:
	print('NO')


n = int(input())
line = input()
trig = True
while trig:
	for i in range(len(line) - 1):
		if line[i] == line[i + 1] != '?':
			print('No')
			trig = False
			break
	if trig == False:
		break
	if line[0] == '?' or line[-1] == '?':
		print('Yes')
		trig = False
		break
	for i in range(1, len(line) - 1):
		if line[i] == line[i + 1] == '?' or (line[i - 1] == line[i + 1] != '?' and line[i] == '?'):
			print('Yes')
			trig = False
			break
	if trig == False:
		break
	print('No')
	break


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

def parse(pr, tail):
	if tail == '':
		return 1
	s = 'CYM' if tail[0] == '?' else tail[0]
	count = 0
	for c in s:
		if c != pr:
			count += parse(c, tail[1:])
		if count > 1:
			return count
	return count
while '????' in s:
	s = s.replace('????', '???')
print('Yes' if parse('', s) > 1 else 'No')


def forced(colors):
	for i in range(1, len(colors) - 1):
		(a, b, c) = (colors[i - 1], colors[i], colors[i + 1])
		if b == '?' and a != '?' and (c != '?') and (a != c):
			colors[i] = 'X'
	return colors

def is_valid(colors):
	for i in range(len(colors) - 1):
		if colors[i] != '?' and colors[i] == colors[i + 1]:
			return False
	return True

def num_qs(colors):
	q = 0
	for c in colors:
		if c == '?':
			q += 1
	return q
input()
colors = list(input())
colors = forced(colors)
good = is_valid(colors) and num_qs(colors) > 0
print('Yes' if good else 'No')


import functools
import sys

def with_args(deco):

	@functools.wraps(deco)
	def wrapper(*args, **kwargs):

		def res(func):
			return deco(func, *args, **kwargs)
		return res
	return wrapper

@with_args
def deco(func, str='я бесполезен'):

	@functools.wraps(func)
	def res(*args, **kwargs):
		print(str, end='\n')
		return func(*args, **kwargs)
	return res

@deco()
def id(x):
	return x

def fib(n):
	a = b = 1
	for i in range(n):
		yield a
		(a, b) = (b, a + b)
(_, s) = (input(), input())
print('Yes' if ('??' in s or 'M?M' in s or 'C?C' in s or ('Y?Y' in s) or (s[0] == '?') or (s[-1] == '?')) and (not ('MM' in s or 'CC' in s or 'YY' in s)) else 'No')


n = int(input())
s = input()
cont = 0
x = s[0]
t = False
t1 = True
if x == '?':
	t = True
for i in range(1, n):
	if s[i] == s[i - 1] and s[i] != '?':
		t1 = False
		break
	if s[i] == '?' and i + 1 != n and (s[i - 1] == s[i + 1]) or (s[i - 1] == '?' and s[i] == '?') or (s[i] == '?' and i + 1 == n):
		t = True
if t == True and t1 == True:
	print('Yes')
else:
	print('No')


n = int(input())
s = input()
if s.count('MM') > 0 or s.count('CC') > 0 or s.count('YY') > 0 or (s.count('?') == 0):
	print('No')
elif s.count('??') > 0 or s[0] == '?' or s[-1] == '?':
	print('Yes')
else:
	for i in range(1, n - 1):
		if s[i] == '?':
			if s[i - 1] == s[i + 1]:
				print('Yes')
				exit()
		if i == n - 2:
			print('No')


n = int(input())
s = '?' + input() + '?'
res = 'Yes'
flex = False
for i in range(1, n + 1):
	if not flex and s[i] == '?':
		if s[i - 1] == '?' or s[i + 1] == '?':
			flex = True
		elif s[i - 1] == s[i + 1]:
			flex = True
	if s[i] != '?' and s[i] == s[i - 1]:
		res = 'No'
		break
if res == 'Yes' and (not flex):
	res = 'No'
print(res)


n = int(input())
string = input()
indices = []
for i in range(n):
	if string[i] == '?':
		indices.append(i)
colors = ['C', 'Y', 'M']

def check_if_no():
	check = False
	for i in range(1, n):
		if string[i] == '?':
			continue
		if string[i] == string[i - 1]:
			check = True
			break
	return check

def boundary_check():
	if 0 in indices or len(string) - 1 in indices:
		return True
	return False

def adjacent_empty():
	check = False
	for i in range(1, len(indices)):
		if indices[i] - indices[i - 1] == 1:
			check = True
			break
	return check

def same_adjacent():
	check = False
	for i in indices:
		if string[i - 1] == string[i + 1]:
			check = True
			break
	return check
if check_if_no():
	print('No')
elif boundary_check():
	print('Yes')
elif adjacent_empty():
	print('Yes')
elif same_adjacent():
	print('Yes')
else:
	print('No')


a = int(input())
b = '!' + input() + '@'
ans = 0
i = 0
while i < a + 1:
	if b[i] != '?' and b[i + 1] != '?' and (b[i] == b[i + 1]):
		ans = 1
	i += 1
if ans:
	print('NO')
else:
	for i in range(1, a + 1):
		s = 0
		if b[i] == '?':
			for j in 'CYM':
				if j != b[i - 1] and j != b[i + 1]:
					s += 1
		if s > 1:
			exit(print('YES'))
	print('NO')


from itertools import accumulate

def rs():
	return input().rstrip()

def ri():
	return int(rs())

def ra():
	return list(map(int, rs().split()))
n = ri()
arr = list(rs())
for (a, b) in zip(arr, arr[1:]):
	if a == b and a != '?':
		print('No')
		exit()
for (num, item) in enumerate(arr):
	if item == '?':
		if num == 0 or num == len(arr) - 1:
			print('Yes')
			exit()
		if arr[num - 1] == arr[num + 1]:
			print('Yes')
			exit()
		if arr[num - 1] == '?':
			print('Yes')
			exit()
		if arr[num + 1] == '?':
			print('Yes')
			exit()
else:
	print('No')


(n, s) = (int(input()), 'A' + input() + 'B')
for i in range(1, n + 1):
	if s[i] in 'CMY' and s[i] == s[i + 1]:
		print('No')
		break
else:
	if s[1] == '?' or s[n] == '?' or '??' in s:
		print('Yes')
	else:
		for i in range(1, n + 1):
			if s[i] == '?' and s[i - 1] == s[i + 1]:
				print('Yes')
				break
		else:
			print('No')


x = int(input())
string = input()
i = 0
counter = 0
right = -1
left = 0
counterik = 0
if string.count('MM') >= 1 or string.count('CC') >= 1 or string.count('YY') >= 1:
	print('NO')
else:
	while i < x:
		if i == 0 and string[i] != '?':
			left = string[i]
			i += 1
			continue
		elif i == 0 and string[i] == '?':
			counter += 2
			break
		elif i == x - 1:
			if string[-1] == '?':
				counter += 2
			break
		right = string[i + 1]
		if string[i] == '?':
			if left == right:
				counter += 2
				break
			elif string[i + 1] == '?':
				counter += 2
				break
			else:
				counter += 1
				counterik += 1
			if string[i + 1] == '?':
				pass
			else:
				left = string[i + 1]
		else:
			left = string[i]
		i += 1
	if counterik == string.count('?'):
		print('NO')
	elif counter >= 2:
		print('YES')
	else:
		print('NO')


n = int(input())
s = input()
ans = 'Yes'
no_int = s.count('?')

def is_cool(s):
	if s.count('??'):
		return True
	else:
		a = s.count('C?C') + s.count('M?M') + s.count('Y?Y')
		return a > 0
ok = s.count('MM') + s.count('CC') + s.count('YY') == 0
if n == 1:
	if s == '?':
		ans = 'Yes'
	else:
		ans = 'No'
elif not ok:
	ans = 'No'
elif no_int == 0:
	ans = 'No'
elif s[0] == '?' or s[-1] == '?':
	ans = 'Yes'
elif s.count('M?C') >= 1:
	if is_cool(s):
		ans = 'Yes'
	else:
		ans = 'No'
elif s.count('M?Y') >= 1:
	if is_cool(s):
		ans = 'Yes'
	else:
		ans = 'No'
elif s.count('C?M') >= 1:
	if is_cool(s):
		ans = 'Yes'
	else:
		ans = 'No'
elif s.count('C?Y') >= 1:
	if is_cool(s):
		ans = 'Yes'
	else:
		ans = 'No'
elif s.count('Y?C') >= 1:
	if is_cool(s):
		ans = 'Yes'
	else:
		ans = 'No'
elif s.count('Y?M') >= 1:
	if is_cool(s):
		ans = 'Yes'
	else:
		ans = 'No'
print(ans)


n = int(input())
a = input()
for i in range(1, n):
	if a[i] == a[i - 1] and a[i] != '?':
		print('No')
		return
for i in range(n):
	if a[i] == '?':
		if i == 0 or i == n - 1:
			print('Yes')
			return
		elif a[i - 1] == '?' or a[i + 1] == '?':
			print('Yes')
			return
		elif a[i - 1] == a[i + 1]:
			print('Yes')
			return
print('No')


n = int(input())
a = input()
if 'MM' in a or 'CC' in a or 'YY' in a:
	print('NO')
elif a[0] == '?' or a[n - 1] == '?':
	print('YES')
	exit(0)
elif '??' in a:
	print('YES')
	exit(0)
else:
	l = len(a)
	for i in range(l):
		if a[i] == '?':
			try:
				if a[i - 1] == a[i + 1]:
					print('YES')
					break
			except:
				continue
		elif i == n - 1:
			print('NO')
			exit(0)


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

def main():
	if '?' not in s:
		print('No')
		return
	for i in range(1, n):
		j = i - 1
		if s[i] == s[j] and s[i] != '?':
			print('No')
			return
	if n == 1:
		print('Yes')
		return
	if s[0] == '?' or s[n - 1] == '?':
		print('Yes')
		return
	for i in range(1, n):
		j = i - 1
		if s[i] == s[j]:
			print('Yes')
			return
	for i in range(2, n):
		i_1 = i - 1
		i_2 = i - 2
		if s[i_2] == s[i] and s[i_1] == '?':
			print('Yes')
			return
	print('No')
	return
main()


n = int(input())
p = input()
f = 1
k = 0
a = 0
for i in range(0, n - 1):
	if p[i] == p[i + 1] and p[i] != '?':
		a += 1
if a >= 1:
	print('No')
elif p[0] == '?' or p[-1] == '?':
	print('Yes')
else:
	while k < n:
		if p[k] == '?':
			if p[k - 1] == p[k + 1]:
				f *= 2
			elif p[k - 1] != '?' and p[k + 1] != '?':
				f *= 1
			else:
				f *= 2
		k += 1
	if f > 1:
		print('Yes')
	else:
		print('No')


def posPaint(n, s):
	temp = s[0]
	for i in range(1, n):
		if s[i] == temp and s[i] != '?':
			return 'No'
		temp = s[i]
	if s[0] == '?' or s[n - 1] == '?':
		return 'Yes'
	else:
		for i in range(1, n - 1):
			b = s[i - 1]
			a = s[i + 1]
			if s[i] == '?' and (b == '?' or a == '?'):
				return 'Yes'
			elif s[i] == '?' and b == a:
				return 'Yes'
		return 'No'
n = int(input())
s = input()
print(posPaint(n, s))


import re

def solve():
	n = input()
	s = input()
	if ('??' in s or 'C?C' in s or 'Y?Y' in s or ('M?M' in s) or (s[0] == '?') or (s[-1] == '?')) and 'CC' not in s and ('YY' not in s) and ('MM' not in s):
		print('YES')
	else:
		print('NO')
solve()


def complete_canvas(s):
	double = False
	res = ''
	for (i, c) in enumerate(s):
		if i > 0 and i < len(s) - 1 and (c == '?') and (s[i - 1] in colors) and (s[i + 1] in colors):
			col = list(colors)
			col.remove(s[i - 1])
			if s[i - 1] != s[i + 1]:
				col.remove(s[i + 1])
			if s[i - 1] == s[i + 1]:
				double = True
			res += col[0]
		else:
			res += c
	return (res, double)

def is_valid(s):
	for (i, c) in enumerate(s):
		if i > 0 and c != '?' and (c == s[i - 1]):
			return False
	return True

def consecutive_undef(s):
	for (i, c) in enumerate(s):
		if i > 0 and c == '?' and (c == s[i - 1]):
			return True
	return False

def is_complete(s):
	return not '?' in s

def extreme_undef(s):
	if s[0] == '?' or s[-1] == '?':
		return True
	return False
import sys
n = int(input())
s = input()
if is_complete(s) or not is_valid(s):
	print('No')
	sys.exit()
possible = set()
colors = set(['M', 'Y', 'C'])
if consecutive_undef(s):
	print('Yes')
	sys.exit()
if extreme_undef(s):
	print('Yes')
	sys.exit()
(s, double) = complete_canvas(s)
if double:
	print('Yes')
	sys.exit()
else:
	print('No')
	sys.exit()


import re

def is_available(picture):
	if re.search('CC|YY|MM', picture):
		return False
	if picture[0] == '?' or picture[-1] == '?':
		return True
	return re.search('C\\?C|M\\?M|Y\\?Y|\\?\\?', picture)
n = int(input())
picture = input().strip()[:n]
print('Yes' if is_available(picture) else 'No')


import sys
import math

def YES():
	print('YES')
	sys.exit()

def NO():
	print('NO')
	sys.exit()
n = int(input())
a = input()
for i in range(n - 1):
	if a[i] == a[i + 1] and a[i] != '?':
		print('NO')
		sys.exit()
for i in range(n):
	if a[i] == '?':
		if i + 1 < n and a[i] == '?' and (a[i + 1] == a[i]):
			YES()
		if i == 0 or i == n - 1:
			YES()
		if i - 1 >= 0 and i + 1 < n and (a[i - 1] == a[i + 1]):
			YES()
NO()
print('YES' if cnt > 1 or q > 1 else 'NO')


import sys

def read_int():
	return int(sys.stdin.readline().strip())

def has_adjcacent(s):
	n = len(s)
	for i in range(n - 1):
		if s[i] == s[i + 1] and s[i] != '?':
			return True
	return False

def can_color(s):
	n = len(s)
	if has_adjcacent(s):
		return False
	if s[0] == '?' or s[-1] == '?':
		return True
	for i in range(1, n - 1):
		if s[i] != '?':
			continue
		if s[i - 1] == s[i + 1] or s[i + 1] == '?':
			return True
	return False
n = read_int()
s = sys.stdin.readline().strip()
print('Yes' if can_color(s) else 'No')


n = int(input())
s = input()
cnt = 0
flag = False
index = 0
for i in s:
	if i == '?':
		cnt = cnt + 1
	else:
		if cnt >= 2:
			flag = True
			break
		elif cnt == 1:
			if index - 2 < 0:
				flag = True
				break
			elif s[index] == s[index - cnt - 1]:
				flag = True
				break
		cnt = 0
	index = index + 1
if cnt > 0:
	flag = True
for i in range(1, len(s)):
	if s[i] == s[i - 1] and s[i] != '?':
		flag = False
if flag:
	print('Yes\n')
else:
	print('No\n')


while True:
	n = int(input())
	s = input()
	for i in range(0, n - 1):
		if s[i] == s[i + 1] and s[i] != '?':
			print('No')
			break
	else:
		if '??' in s or 'Y?Y' in s or 'C?C' in s or ('M?M' in s) or (s[0] == '?') or (s[-1] == '?'):
			print('Yes')
		else:
			print('No')
	break


n = int(input())
s = str(input())
x = True
X = False
if 'MM' in s or 'YY' in s or 'CC' in s:
	x = False
if x:
	if '??' in s:
		X = True
	elif 'Y?Y' in s or 'C?C' in s or 'M?M' in s:
		X = True
	elif s[0] == '?' or s[-1] == '?':
		X = True
if X:
	print('Yes')
else:
	print('No')


import sys
n = int(input())
s = input()
m = 0
x = ''
flag = 0
for i in range(0, n):
	if i < n - 1:
		if s[i] == s[i + 1] and s[i] != '?':
			print('No')
			sys.exit()
	if s[0] == '?' or s[n - 1] == '?':
		flag = 1
	if s[i] == 'C' or s[i] == 'M' or s[i] == 'Y':
		if x == s[i] and m == 1:
			flag = 1
		elif m > 1:
			flag = 1
		m = 0
		x = s[i]
	if s[i] == '?':
		m = m + 1
if flag == 1:
	print('Yes')
else:
	print('No')


n1 = input()
n = int(n1)
s = []
flag = True
sc = input()
for i in range(n):
	s.append(sc[i])
	if i > 0:
		if s[i] == s[i - 1] and s[i] != '?':
			flag = False
			break
if flag == False:
	print('NO')
	exit()
flag = False
for i in range(n):
	if s[i] == '?':
		if i == 0 or i == n - 1:
			flag = True
			break
		elif s[i - 1] == s[i + 1] or s[i + 1] == '?':
			flag = True
			break
if flag:
	print('YES')
else:
	print('NO')


def main():
	n = int(input())
	s = input()
	prev = ''
	for char in s:
		if char != '?' and char == prev:
			print('No')
			return
		prev = char
	if 'C?C' in s or 'M?M' in s or 'Y?Y' in s or ('??' in s) or (s[0] == '?') or (s[-1] == '?'):
		print('Yes')
		return
	else:
		print('No')
		return
main()


import math, sys, bisect, heapq
from collections import defaultdict, Counter, deque
from itertools import groupby, accumulate
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda : map(int, input().split())
alele = lambda : list(map(int, input().split()))

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 Y(c):
	print(['NO', 'YES'][c])

def y(c):
	print(['no', 'yes'][c])

def Yy(c):
	print(['No', 'Yes'][c])
N = int(input())
S = input()
f = 1
for i in range(N - 1):
	x = S[i] + S[i + 1]
	if x in ['YY', 'CC', 'MM']:
		f = 0
		break
if f == 0:
	print('No')
elif S[-1] == '?' or S[0] == '?':
	print('Yes')
elif '??' in S:
	print('Yes')
else:
	g = 0
	for i in range(N):
		if S[i] == '?':
			if S[i - 1] == S[i + 1]:
				g = 1
				break
	Yy(g)


n = int(input())
a = input()
a = list(a)
t = 0
g = a.count('?')
if g == 0:
	print('No')
	exit()
for i in range(n - 1):
	j = i + 1
	if a[i] == a[j] and a[i] != '?':
		print('No')
		exit()
for i in range(1, n - 1):
	if a[i - 1] != a[i + 1] and a[i] == '?' and (a[i - 1] != '?' and a[i + 1] != '?'):
		t += 1
if t >= g and t != 0:
	print('no')
	exit()
print('Yes')


n = int(input())
s = input()
dp = [[0] * 3]
if s[0] == 'C' or s[0] == '?':
	dp[0][0] = 1
if s[0] == 'M' or s[0] == '?':
	dp[0][1] = 1
if s[0] == 'Y' or s[0] == '?':
	dp[0][2] = 1
for i in range(1, n):
	dp.append([0] * 3)
	if s[i] == 'C' or s[i] == '?':
		dp[i][0] = dp[i - 1][1] + dp[i - 1][2]
	if s[i] == 'M' or s[i] == '?':
		dp[i][1] = dp[i - 1][0] + dp[i - 1][2]
	if s[i] == 'Y' or s[i] == '?':
		dp[i][2] = dp[i - 1][0] + dp[i - 1][1]
if dp[n - 1][0] + dp[n - 1][1] + dp[n - 1][2] >= 2:
	print('Yes')
else:
	print('No')


n = input()
s = list(input())
for i in range(1, len(s)):
	if s[i] != '?' and s[i] == s[i - 1]:
		print('No')
		exit()
for i in range(len(s)):
	if s[i] == '?':
		if i == 0 or i == len(s) - 1 or s[i + 1] == '?' or (s[i - 1] == s[i + 1]):
			print('Yes')
			exit()
print('No')


n = int(input())
s = input()
for i in range(n - 1):
	if s[i] == s[i + 1] and s[i] != '?':
		print('NO')
		quit()
ans = 'No'
for i in range(n - 1):
	if s[i] == s[i + 1] == '?':
		ans = 'YES'
		break
	elif s[i] == '?':
		if i == 0 or s[i - 1] == s[i + 1]:
			ans = 'YES'
			break
if s[n - 1] == '?':
	ans = 'YES'
print(ans)


_B3 = ['CC', 'MM', 'YY']
_B4 = ['M?M', 'C?C', 'Y?Y']

def __(___, _XB3):
	for _X2 in range(3):
		if ___.count(_XB3[_X2]) > 0:
			return True
	return False

def _SL2(___, _XB4):
	for _X3 in range(3):
		if ___.count(_XB4[_X3]) > 0:
			return True
	return False
input()
_ = input()
if __(_, _B3) or _.count('?') == 0:
	print('No')
elif _[0] == '?' or _[len(_) - 1] == '?' or _SL2(_, _B4) or (_.count('??') > 0):
	print('Yes')
else:
	print('No')


n = int(input())
s = input()
assert len(s) == n
for c in 'CMY':
	if c * 2 in s:
		print('No')
		exit()
if s.startswith('?') or s.endswith('?'):
	print('Yes')
	exit()
if '??' in s:
	print('Yes')
	exit()
for c in 'CMY':
	if '?'.join((c, c)) in s:
		print('Yes')
		exit()
print('No')
__test__ = '\nCY??Y\nC?C?Y\n?CYC?\nC??MM\nMMY\n'


n = int(input())
a = input()
flag = 0
for (ind, a_i) in enumerate(a):
	if ind == 0:
		continue
	elif a_i == a[ind - 1] and a_i != '?':
		flag = 1
		break
if flag == 1:
	print('No')
elif a.count('?') >= 2:
	flag = 0
	for (ind, a_i) in enumerate(a):
		if ind != 0 and ind != n - 1:
			if a_i == '?' and a[ind - 1] == a[ind + 1] or (a_i == '?' and (a[ind - 1] == '?' or a[ind + 1] == '?')):
				flag = 1
				break
		elif ind == 0 and a_i == '?' or (ind == n - 1 and a_i == '?'):
			flag = 1
			break
	print('Yes' if flag == 1 else 'No')
elif a.count('?') == 0:
	print('No')
else:
	ind = a.index('?')
	if ind == 0 or ind == n - 1:
		print('Yes')
	elif a[ind - 1] == a[ind + 1]:
		print('Yes')
	else:
		print('No')


n = int(input())
s = input()
e = True
t = True
for i in range(n - 1):
	if s[i:i + 2] == 'YY' or s[i:i + 2] == 'MM' or s[i:i + 2] == 'CC':
		t = False
		break
if t == True:
	if s[0] == '?' or s[n - 1] == '?':
		e = False
	else:
		for i in range(1, n - 1):
			if s[i] == '?':
				if s[i + 1] == '?':
					e = False
					break
				elif s[i - 1] == s[i + 1]:
					e = False
					break
			if e == False:
				break
if t == True and e == False:
	print('Yes')
else:
	print('No')


import re
smem = {}
dmem = {}

def S(n):
	global smem
	if n == 0:
		return 1
	if n in smem:
		return smem[n]
	smem[n] = 2 * D(n - 1)
	return smem[n]

def D(n):
	global dmem
	if n == 0:
		return 1
	if n == 1:
		return 1
	elif n == 2:
		return 3
	if n in dmem:
		return dmem[n]
	dmem[n] = 2 * D(n - 1) + S(n - 1)
	return dmem[n]
n = int(input())
s = input()
L = [(m.start(0), m.end(0) - 1) for m in re.finditer('[?]+', s)]
res = []
for (a, b) in L:
	l = b - a + 1
	if a == 0:
		if b == n - 1:
			print('Yes')
			exit()
		else:
			res.append(2 ** l)
	elif b == n - 1:
		if a == 0:
			print('Yes')
			exit()
		else:
			res.append(2 ** l)
	elif s[a - 1] != '?':
		if s[b + 1] != '?':
			if s[a - 1] == s[b + 1]:
				res.append(S(l))
			else:
				res.append(D(l))
for (a, b) in zip(s, s[1:]):
	if a == '?':
		continue
	if a == b:
		print('No')
		exit()
real = 1
for x in res:
	real *= x
if real < 2:
	print('No')
else:
	print('Yes')


n = int(input())
a = input()
f = 0
for i in range(n - 1):
	if a[i] == a[i + 1] and a[i] != '?':
		f = 1
		break
if f:
	print('No')
else:
	o = a[0]
	for i in range(1, n - 1):
		if a[i] == '?':
			if a[i - 1] != '?' and a[i + 1] != '?' and (a[i - 1] != a[i + 1]):
				o += 'X'
			else:
				o += a[i]
		else:
			o += a[i]
	o += a[-1]
	if '?' in o:
		print('Yes')
	else:
		print('No')


def solve(s):
	if 'MM' in s or 'CC' in s or 'YY' in s:
		return False
	if '??' in s or 'C?C' in s or 'M?M' in s or ('Y?Y' in s):
		return True
	if s.startswith('?') or s.endswith('?'):
		return True
	return False
input()
s = input()
print(['No', 'Yes'][solve(s)])


n = int(input())
s = input()
if (s.find('??') >= 0 or s[0] == '?' or s[-1] == '?' or any((s.find(c + '?' + c) >= 0 for c in ['C', 'M', 'Y']))) and all((s.find(x) < 0 for x in ['CC', 'MM', 'YY'])):
	print('Yes')
else:
	print('No')


import sys
n = int(input())
string1 = input()
string2 = string1
array = ['C', 'Y', 'M']
flag = 1
for i in range(0, len(string2) - 1):
	if string2[i] != '?' and string2[i] == string2[i + 1]:
		print('No')
		sys.exit()
if string2[0] == '?' or string2[len(string2) - 1] == '?':
	print('Yes')
	sys.exit()
for i in range(1, len(string2) - 1):
	if string2[i] == '?':
		if string2[i - 1] == string2[i + 1] or string2[i + 1] == '?':
			flag = 0
			break
if flag == 1:
	print('No')
else:
	print('Yes')


n = int(input())
a = input()
flag = 0
for i in range(len(a)):
	if (i == 0 or i == n - 1) and a[i] == '?':
		flag = 1
for i in range(1, len(a) - 1):
	if a[i] == '?' and (a[i - 1] == a[i + 1] or a[i - 1] == '?' or a[i + 1] == '?'):
		flag = 1
for i in range(1, len(a)):
	if a[i] == a[i - 1] and a[i] != '?':
		flag = 0
		break
if flag:
	print('Yes')
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()
n = int(I1())
s = I1().strip()
(i, f) = (0, 0)
for j in range(1, n):
	if s[j] == s[j - 1] and s[j] != '?':
		print('No')
		exit()
while i < n:
	if s[0] == '?' or s[n - 1] == '?':
		f = 1
		break
	elif s[i] == '?':
		j = i + 1
		while s[j] == '?':
			j += 1
		if s[i - 1] == s[j] or (s[i - 1] != s[j] and j - i > 1):
			f = 1
			break
	i += 1
if f == 1:
	print('Yes')
else:
	print('No')


n = int(input())
clrs = '?' + input().strip() + '?'
if clrs.find('CC') >= 0 or clrs.find('MM') >= 0 or clrs.find('YY') >= 0:
	print('No')
	exit()
if clrs.find('??') >= 0 or clrs.find('C?C') >= 0 or clrs.find('M?M') >= 0 or (clrs.find('Y?Y') >= 0):
	print('Yes')
	exit()
print('No')


input()
s = input()
if 'MM' in s or 'YY' in s or 'CC' in s:
	print('No')
elif s.startswith('?') or s.endswith('?'):
	print('Yes')
elif '??' in s:
	print('Yes')
elif 'C?C' in s or 'M?M' in s or 'Y?Y' in s:
	print('Yes')
else:
	print('No')


n = int(input())
ch = input()
if 'CC' in ch or 'MM' in ch or 'YY' in ch:
	print('No')
elif '??' in ch:
	print('Yes')
elif ch[0] == '?':
	print('Yes')
elif ch[n - 1] == '?':
	print('Yes')
elif '?' not in ch:
	print('No')
else:
	x = False
	for i in range(1, len(ch) - 1):
		if ch[i] == '?':
			if ch[i - 1] == ch[i + 1]:
				x = True
				break
	if x:
		print('Yes')
	else:
		print('No')


import os
from math import *
n = int(input())
s = input()
if 'CC' in s or 'MM' in s or 'YY' in s:
	print('No')
elif '??' in s:
	print('Yes')
elif s[0] == '?' or s[-1] == '?':
	print('Yes')
else:
	y = 0
	for i in range(1, n):
		if s[i] == '?':
			if s[i - 1] == s[i + 1]:
				print('Yes')
				y = 1
				break
	if y == 0:
		print('No')


from functools import reduce
N = int(input())
colors = input()

def compare(x, y):
	if x == False or (x == y and (x == 'C' or x == 'M' or x == 'Y')):
		return False
	return y

def check_for(colors):
	if colors[0] == '?' or colors[-1] == '?':
		return True
	for i in range(1, len(colors) - 1):
		if colors[i] == '?' and (colors[i - 1] == colors[i + 1] or colors[i + 1] == '?'):
			return True
	return False

def logic(colors):
	print('Yes') if reduce(compare, colors) and check_for(colors) else print('No')
logic(colors)


n = int(input())
a = input()
for i in range(1, len(a)):
	if a[i] == a[i - 1] and a[i - 1] != '?':
		print('No')
		exit()
for i in range(1, len(a) - 1):
	if a[i] == '?' and (a[i - 1] == a[i + 1] or (a[i - 1] == a[i] or a[i + 1] == a[i])):
		print('Yes')
		exit()
if a[0] == '?' or a[-1] == '?':
	print('Yes')
	exit()
print('No')


n = input()
s = input()
colors = {'C', 'Y', 'M'}

def res():
	for c in colors:
		if s.find(c * 2) != -1:
			return 'No'
	if s[0] == '?':
		return 'Yes'
	if s[len(s) - 1] == '?':
		return 'Yes'
	if s.find('??') != -1:
		return 'Yes'
	for c in colors:
		if s.find(c + '?' + c) != -1:
			return 'Yes'
	return 'No'
print(res())


import re
input()
s = input()
if re.findall('C{2,}|M{2,}|Y{2,}', s):
	print('No')
	exit()
if s.startswith('?') or s.endswith('?'):
	print('Yes')
	exit()
s = ' ' + s + ' '
l = 0
for (i, j) in enumerate(s):
	if '?' == j:
		l += 1
	else:
		if l == 1:
			if s[i - 2] == s[i]:
				print('Yes')
				break
		if l >= 2:
			print('Yes')
			break
		l = 0
else:
	print('No')


n = int(input())
ch = input()
if ch.count('?') == 0:
	print('NO')
elif 'CC' in ch:
	print('NO')
elif 'MM' in ch:
	print('NO')
elif 'YY' in ch:
	print('NO')
elif 'M?M' in ch or 'C?C' in ch or 'Y?Y' in ch:
	print('YES')
elif ch[0] == '?':
	print('YES')
elif 'C?Y' in ch and 'C?Y?Y' not in ch and ('C?C?Y' not in ch):
	print('NO')
elif 'C?M' in ch and 'C?M?M' not in ch and ('C?C?M' not in ch):
	print('NO')
elif 'M?C' in ch and 'M?C?C' not in ch and ('M?M?C' not in ch):
	print('NO')
elif 'M?Y' in ch and 'M?Y?Y' not in ch and ('M?M?Y' in ch):
	print('NO')
elif 'Y?C' in ch and 'Y?C?C' not in ch and ('Y?Y?C' in ch):
	print('NO')
elif 'Y?M' in ch and 'Y?M?M' not in ch and ('Y?Y?M' in ch):
	print('NO')
else:
	print('YES')


n = int(input())
s = list(input())
if s.count('?') == 0:
	print('No')
	exit(0)
f = 0
a = s[0]
for i in range(1, n):
	if s[i] == s[i - 1] and s[i] != '?':
		f = 1
		print('No')
		exit(0)
s = ['*'] + s + ['&']
y = list('CMY')
for i in range(1, n + 1):
	g = 0
	if s[i - 1] in y and s[i + 1] in y:
		g = 1
	if s[i] == '?' and s[i - 1] == s[i + 1] and (g == 1) or (g == 0 and s[i] == '?'):
		print('Yes')
		exit(0)
print('No')


n = int(input())
s = input()
a = ['MM', 'YY', 'CC']
c = 1
for i in a:
	if i in s:
		c = 0
		break
if c == 0:
	print('No')
elif s[0] == '?' or s[n - 1] == '?':
	print('Yes')
elif '??' in s or 'Y?Y' in s or 'M?M' in s or ('C?C' in s):
	print('Yes')
else:
	print('No')


import sys

def input():
	return sys.stdin.readline()[:-1]
n = int(input())
s = input()

def no():
	print('No')
	exit()

def yes():
	print('Yes')
	exit()
for i in range(n - 1):
	if s[i] != '?' and s[i] == s[i + 1]:
		no()
for i in range(n):
	if s[i] == '?':
		if i == 0 or i == n - 1:
			yes()
		if s[i + 1] == s[i]:
			yes()
		if s[i + 1] == s[i - 1]:
			yes()
no()


n = int(input())
si = input()
flag = True
if 'MM' in si or 'CC' in si or 'YY' in si or (not '?' in si):
	print('No')
elif '???' in si or '??' in si:
	print('Yes')
elif si.startswith('?') or si.endswith('?'):
	print('Yes')
else:
	for k in range(n):
		if si[k] == '?' and si[k - 1] == si[k + 1]:
			print('Yes')
			flag = False
			break
	if flag:
		print('No')


n = int(input())
s = input()
res = '?' in s and all((c not in s for c in ['CC', 'MM', 'YY']))
if res:
	res = any((c in s for c in ['C?C', 'M?M', 'Y?Y', '??', '???']))
	res |= '?' in (s[0], s[-1])
print('Yes' if res else 'No')


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

def yes():
	print('YES')
	exit()

def no():
	print('NO')
	exit()
if s.find('YY') >= 0:
	no()
if s.find('CC') >= 0:
	no()
if s.find('MM') >= 0:
	no()
if s.find('???') >= 0 or s.find('??') >= 0:
	yes()
if s.find('C?C') >= 0:
	yes()
if s.find('M?M') >= 0:
	yes()
if s.find('Y?Y') >= 0:
	yes()
if s[0] == '?' or s[-1] == '?':
	yes()
no()


N = int(input())
Array = list(map(str, input().split()[:N]))
s = ''.join(Array)
C = s.find('CC')
M = s.find('MM')
Y = s.find('YY')
a = s.find('C?Y')
b = s.find('C?M')
c = s.find('M?Y')
d = s.find('M?C')
e = s.find('Y?C')
f = s.find('Y?M')
g = s.find('?')
h = s.find('C?C')
i = s.find('Y?Y')
j = s.find('M?M')
k = s.find('??')
l = s.find('???')
m = s.find('????')
n = s.find('?????')
o = s.find('??????')
if Y == -1 and M == -1 and (C == -1) and (a == -1) and (b == -1) and (c == -1) and (d == -1) and (e == -1) and (f == -1) and (g != -1) or ((a != -1 or b != -1 or c != -1 or (d != -1) or (e != -1) or (f != -1)) and (h != -1 or i != -1 or j != -1 or (k != -1) or (l != -1) or (m != -1) or (n != -1) or (o != -1) or (g == 0))):
	print('Yes')
else:
	print('No')


n = int(input())
s = list(input())
k = 0
idx = -1
possible = False
for i in range(n):
	if s[i] == '?':
		k += 1
		idx = i
	else:
		if i < n - 1:
			if s[i] == s[i + 1]:
				possible = False
				break
		if k > 1:
			possible = True
		elif k == 1:
			if idx == 0:
				possible = True
			elif s[idx - 1] == s[idx + 1]:
				possible = True
		k = 0
if idx == n - 1:
	possible = True
if possible:
	print('Yes')
else:
	print('No')


n = int(input())
s = input()
a = True
t = 0
for i in range(n - 1):
	if s[i] == s[i + 1] and s[i] != '?':
		a = False
		break
if a:
	t = s.count('?')
	for i in range(1, n - 1):
		if s[i] == '?' and s[i - 1] != s[i + 1] and (s[i - 1] != '?') and (s[i + 1] != '?'):
			t -= 1
if t > 0 and a:
	print('Yes')
else:
	print('No')


n = int(input())
s = input()
for i in range(n - 1):
	if s[i] == s[i + 1] != '?':
		print('No')
		exit(0)
for i in range(1, n - 1):
	if s[i] == '?' and len(set([s[i - 1], s[i + 1]]) & set('CYM')) != 2:
		print('Yes')
		exit(0)
if s[0] == '?' or s[-1] == '?':
	print('Yes')
	exit(0)
print('No')


def isColored(n, paintedCanvas):
	for i in range(1, n):
		if paintedCanvas[i] != '?' and paintedCanvas[i - 1] == paintedCanvas[i]:
			return 'No'
	colors = {'C', 'M', 'Y'}
	twoIsPossible = False
	option1 = paintedCanvas
	for i in range(n):
		consecutiveColors = set()
		if option1[i] == '?':
			if i > 0:
				consecutiveColors.add(option1[i - 1])
			if i < n - 1 and paintedCanvas[i + 1] != '?':
				consecutiveColors.add(option1[i + 1])
			possibleColors = colors - consecutiveColors
			if len(possibleColors) > 1:
				twoIsPossible = True
			if len(possibleColors) < 1:
				return 'No'
			option1.replace('?', possibleColors.pop(), 1)
	if twoIsPossible == True:
		return 'Yes'
	return 'No'
n = input()
paintedCanvas = input()
print(isColored(int(n), paintedCanvas))


input()
a = input()
print('YES' if (any((i in a for i in ['??', 'C?C', 'Y?Y', 'M?M'])) or a[0] == '?' or a[-1] == '?') and all((i not in a for i in ['MM', 'YY', 'CC'])) else 'NO')


x = int(input())
myStr = input()

def func(myStr):
	choice = 0
	n = len(myStr)
	for (i, c) in enumerate(myStr):
		if c != '?':
			if i + 1 < n:
				if c == myStr[i + 1]:
					return False
					break
		elif c == '?' and choice < 2:
			if i + 1 < n:
				if c == myStr[i + 1]:
					choice += 2
				elif i - 1 < 0:
					choice += 2
				elif myStr[i - 1] == myStr[i + 1]:
					choice += 2
				else:
					continue
			else:
				choice += 2
	if choice >= 2:
		return True
	else:
		return False
z = func(myStr)
if z == True:
	print('Yes')
else:
	print('No')


n = int(input())
s = input()
numberOfways = 1
for i in range(n - 1):
	if s[i] == '?':
		if i == 0:
			if s[i + 1] == '?':
				numberOfways *= 3
			else:
				numberOfways *= 2
		elif s[i - 1] == s[i + 1] or (s[i - 1] != '?' and s[i + 1] == '?'):
			numberOfways *= 2
	elif s[i + 1] == s[i]:
		numberOfways *= 0
	else:
		pass
	if i == n - 2 and s[i + 1] == '?':
		numberOfways *= 2
if n == 1 and s[0] == '?':
	numberOfways = 3
if numberOfways > 1:
	print('Yes')
else:
	print('No')


n = int(input())
for _ in range(1):
	s = input().rstrip()
	f1 = True
	fl1 = False
	for i in range(1, len(s)):
		if s[i] is not '?' and s[i] is s[i - 1]:
			f1 = False
			break
	if f1:
		if s[0] is '?' or s[len(s) - 1] is '?':
			print('Yes')
			fl1 = False
		elif s.count('?') == 0:
			print('No')
			fl1 = False
		else:
			f = False
			last = -1
			for i in range(len(s)):
				if s[i] is '?':
					if not f:
						last = i
						f = True
				elif f:
					l = i - last
					if l > 1:
						print('Yes')
						fl1 = False
						break
					else:
						if s[last - 1] is s[i]:
							print('Yes')
							fl1 = False
							break
						else:
							fl1 = True
						f = False
	else:
		print('No')
	if fl1:
		print('No')