Walking along a riverside, Mino silently takes a note of something.

"Time," Mino thinks aloud.

"What?"

"Time and tide wait for no man," explains Mino. "My name, taken from the river, always reminds me of this."

"And what are you recording?"

"You see it, tide. Everything has its own period, and I think I've figured out this one," says Mino with confidence.

Doubtfully, Kanno peeks at Mino's records. 

The records are expressed as a string s of characters '0', '1' and '.', where '0' denotes a low tide, '1' denotes a high tide, and '.' denotes an unknown one (either high or low).

You are to help Mino determine whether it's possible that after replacing each '.' independently with '0' or '1', a given integer p is not a period of the resulting string. In case the answer is yes, please also show such a replacement to Mino.

In this problem, a positive integer p is considered a period of string s, if for all 1 ≤ i ≤ \lvert s \rvert - p, the i-th and (i + p)-th characters of s are the same. Here \lvert s \rvert is the length of s.

Input

The first line contains two space-separated integers n and p (1 ≤ p ≤ n ≤ 2000) — the length of the given string and the supposed period, respectively.

The second line contains a string s of n characters — Mino's records. s only contains characters '0', '1' and '.', and contains at least one '.' character.

Output

Output one line — if it's possible that p is not a period of the resulting string, output any one of such strings; otherwise output "No" (without quotes, you can print letters in any case (upper or lower)).

Examples

Input

10 7
1.0.1.0.1.


Output

1000100010


Input

10 6
1.0.1.1000


Output

1001101000


Input

10 9
1........1


Output

No

Note

In the first example, 7 is not a period of the resulting string because the 1-st and 8-th characters of it are different.

In the second example, 6 is not a period of the resulting string because the 4-th and 10-th characters of it are different.

In the third example, 9 is always a period because the only constraint that the first and last characters are the same is already satisfied.

Note that there are multiple acceptable answers for the first two examples, you can print any of them.

Difficulty: EASY
Tags: String algorithms

Constructive algorithms

Starter code:

Solutions:
(n, p) = [int(i) for i in input().split()]
s = list(input())
k = 0
for index in range(n - p):
	if k != 0:
		break
	if s[index] == s[index + p] and s[index] == '.':
		s[index] = str(0)
		s[index + p] = str(1)
		k += 1
	elif s[index] != s[index + p] and s[index] != '.' and (s[index + p] != '.'):
		k += 1
	elif s[index] != s[index + p] and (s[index] == '.' or s[index + p] == '.'):
		if s[index] == '.':
			s[index] = str(int(not int(s[index + p])))
		else:
			s[index + p] = str(int(not int(s[index])))
		k += 1
s = ''.join(s)
print('No' if k == 0 else s.replace('.', str(0)))


(n, p) = list(map(int, input().split()))
ss1 = input()
ss = [x for x in ss1]
import sys

def gn(v):
	if v == '1':
		return '0'
	return '1'
for i in range(len(ss)):
	for j in range(i, len(ss), p):
		if i == j:
			continue
		if ss[i] != ss[j]:
			if ss[i] != '.' and ss[j] != '.':
				pass
			elif ss[i] != '.':
				ss[j] = gn(ss[i])
			else:
				ss[i] = gn(ss[j])
			print(''.join(ss).replace('.', '0'))
			sys.exit()
		if ss[i] == ss[j] and ss[i] == '.':
			ss[i] = '1'
			ss[j] = '0'
			res = ''.join(ss).replace('.', '0')
			print(res)
			sys.exit()
print('No')


(l, p) = map(lambda x: int(x), input().strip().split(' '))
s = list(input())
i = 0
periodFlag = True
for i in range(len(s) - p):
	if s[i] == '.' and s[i + p] == '.':
		periodFlag = False
		s[i] = '0'
		s[i + p] = '1'
		break
	elif s[i] == '.' and s[i + p] == '0':
		s[i] = '1'
		periodFlag = False
		break
	elif s[i] == '.' and s[i + p] == '1':
		s[i] = '0'
		periodFlag = False
		break
	elif s[i + p] == '.' and s[i] == '0':
		s[i + p] = '1'
		periodFlag = False
		break
	elif s[i + p] == '.' and s[i] == '1':
		s[i + p] = '0'
		periodFlag = False
		break
	elif s[i] != s[i + p]:
		periodFlag = False
		break
if periodFlag:
	print('No')
else:
	for i in range(len(s)):
		if s[i] == '.':
			s[i] = '0'
	print(''.join(s))


yoar = list(map(int, input().split()))
n = yoar[0]
p = yoar[1]
s = list(input())
flag = 0
for i in range(n - p):
	if s[i] == s[i + p] != '.':
		flag += 1
		continue
	elif s[i] == s[i + p] == '.':
		s[i] = '0'
		s[i + p] = '1'
	elif s[i] == '1':
		if s[i + p] == '0':
			continue
		elif s[i + p] == '.':
			s[i + p] = '0'
	elif s[i + p] == '1':
		if s[i] == '0':
			continue
		elif s[i] == '.':
			s[i] = '0'
	elif s[i] == '0':
		if s[i + p] == '1':
			continue
		elif s[i + p] == '.':
			s[i + p] = '1'
	elif s[i + p] == '0':
		if s[i] == '1':
			continue
		elif s[i] == '.':
			s[i] = '1'
if flag == n - p:
	print('No')
else:
	for i in range(n):
		if s[i] == '.':
			s[i] = '0'
	for i in s:
		print(i, end='')
	print()


(n, p) = [int(x) for x in input().split()]
x = input()
chosen = -1
for i in range(0, len(x) - p):
	if x[i] == '.':
		chosen = i
		different = i + p
		break
	elif x[i + p] == '.':
		chosen = i + p
		different = i
		break
	elif x[i] != x[i + p]:
		chosen = 'noneed'
		break
if chosen == -1:
	print('No')
elif chosen == 'noneed':
	for i in x:
		if i == '.':
			print(1, end='')
		else:
			print(int(i), end='')
else:
	for i in range(0, len(x)):
		if x[i] != '.':
			print(int(x[i]), end='')
		elif i == chosen:
			if x[different] == '.':
				print(1, end='')
			else:
				print(1 - int(x[different]), end='')
		elif i == different:
			print(0, end='')
		else:
			print(1, end='')


(n, p) = map(int, input().split())
s = input()
a = []
for i in s:
	a += [i]
flag = 0
for i in range(0, n - p):
	if a[i] == a[i + p] and a[i] != '.' and (a[i + p] != '.'):
		flag += 1
	elif a[i] == '.' and a[i + p] == '.':
		a[i] = '0'
		a[i + p] = '1'
	elif a[i] == '.':
		if a[i + p] == '0':
			a[i] = '1'
		else:
			a[i] = '0'
	elif a[i + p] == '.':
		if a[i] == '0':
			a[i + p] = '1'
		else:
			a[i + p] = '0'
if flag == n - p:
	print('NO')
else:
	for i in range(n):
		if a[i] == '.':
			a[i] = '1'
	print(''.join(a))


(n, p) = map(int, input().split())
s = list(input())
f = 0
for i in range(n):
	if s[i] == '.':
		s[i] = '0'
		if i - p >= 0 and s[i - p] == '0' or (i + p < n and s[i + p] == '0'):
			s[i] = '1'
	if i + p < n and s[i + p] != s[i]:
		f = 1
if f == 1:
	print(''.join(s))
else:
	print('No')


(n, p) = map(int, input().split())
s = input()
a = ['.'] * p
b = list(s)
go = False
for i in range(0, n, p):
	for j in range(p):
		if i + j >= n:
			break
		if s[i + j] == '.':
			x = i + j
			if x - p >= 0:
				if b[x - p] == '.':
					b[x - p] = '1'
					b[x] = '0'
				else:
					b[x] = str(1 - int(b[x - p]))
				go = True
				break
			elif x + p < n:
				if b[x + p] == '.':
					b[x + p] = '1'
					b[x] = '0'
				else:
					b[x] = str(1 - int(b[x + p]))
				go = True
				break
		elif a[j] == '.':
			a[j] = s[i + j]
		elif a[j] != s[i + j]:
			go = True
			break
	else:
		continue
	break
for i in range(len(b)):
	if b[i] == '.':
		b[i] = '1'
if go:
	for i in b:
		print(i, end='')
else:
	print('nO')


def check(arr):
	if len(arr) == 1:
		return (False, list(''.join(arr).replace('.', '1')))
	ds = set(arr)
	if len(ds) > 1:
		fail = True
		if '1' in ds:
			return (True, list(''.join(arr).replace('.', '0')))
		else:
			return (True, list(''.join(arr).replace('.', '1')))
	if '.' in ds:
		arr[0] = '0'
		arr[1] = '1'
		return (True, list(''.join(arr).replace('.', '1')))
	return (False, list(''.join(arr).replace('.', '1')))
(n, p) = map(int, input().split())
inst = list(input().strip())
if n < p:
	print('No')
	exit()
fail = False
for k in range(p):
	(fail, inst[k::p]) = check(inst[k::p])
	if fail:
		print(''.join(inst).replace('.', '1'))
		exit()
print('No')


per = False
(n, p) = map(int, input().split())
s = list(input())
for a in range(p):
	if per:
		break
	for b in range(a + p, n + n, p):
		if b >= n:
			break
		if s[a] != s[b] and s[a] != '.' and (s[b] != '.'):
			per = True
			break
		if s[a] == '.':
			if s[b] == '1':
				s[a] = '0'
			elif s[b] == '0':
				s[a] = '1'
			else:
				s[a] = '1'
				s[b] = '0'
			per = True
			break
		elif s[b] == '.':
			if s[a] == '1':
				s[b] = '0'
			else:
				s[b] = '1'
			per = True
			break
if per:
	for i in range(n):
		if s[i] == '.':
			s[i] = '1'
	print(''.join(s))
else:
	print('No')


(n, m) = [int(i) for i in input().split()]
a = list(input())
l = len(a)
f = False
for i in range(l - m):
	if not (a[i] == a[i + m] and (a[i] != '.' and a[i + m] != '.')):
		f = True
		if a[i] == '.':
			if a[i + m] == '1':
				a[i] = '0'
			else:
				a[i] = '1'
		if a[i + m] == '.':
			if a[i] == '0':
				a[i + m] = '1'
			else:
				a[i + m] = '0'
if f == False:
	print('No')
	quit()
for i in a:
	if i == '.':
		i = '0'
	print(i, end='')
print()


(n, p) = map(int, input().split())
c = 0
st1 = []
st0 = []
fl = False
str_ = input()
for l in str_:
	if l == '.':
		if c - p >= 0 or c + p < n:
			if c - p >= 0:
				delt = c - p
			else:
				delt = c + p
			t = str_[delt]
			if t == '0':
				str_ = list(str_)
				str_[c] = '1'
				str_ = ''.join(str_).replace('.', '0')
				fl = True
				break
			elif t == '1':
				str_ = list(str_)
				str_[c] = '0'
				str_ = ''.join(str_).replace('.', '0')
				fl = True
				break
			elif t == '.':
				str_ = list(str_)
				str_[c] = '1'
				str_[delt] = '0'
				str_ = ''.join(str_).replace('.', '0')
				fl = True
				break
	if st1:
		if c == st1[0]:
			if l == '0':
				str_.replace('.', '0')
				fl = True
				break
			else:
				st1.pop(0)
	if st0:
		if c == st0[0]:
			if l == '1':
				str_.replace('.', '0')
				fl = True
				break
			else:
				st0.pop(0)
	if l == '0':
		st0.append(c + p)
	elif l == '1':
		st1.append(c + p)
	c += 1
str_ = str_.replace('.', '0')
print(str_ if fl else 'No')


import sys
import string
from collections import Counter, defaultdict
from math import fsum, sqrt, gcd, ceil, factorial
from operator import add
inf = float('inf')
flush = lambda : sys.stdout.flush
comb = lambda x, y: factorial(x) // factorial(y) // factorial(x - y)
ip = lambda : input()
ii = lambda : int(input())
r = lambda : map(int, input().split())
rr = lambda : list(r())
(n, k) = r()
s = list(ip())
c = 0
for i in range(n - k):
	if s[i] == s[i + k] != '.':
		c += 1
	elif s[i] == s[i + k] == '.':
		s[i] = '0'
		s[i + k] = '1'
	elif s[i] == '.':
		s[i] = '1' if s[i + k] == '0' else '0'
	else:
		s[i + k] = '1' if s[i] == '0' else '0'
if c == n - k:
	print('No')
else:
	s = ''.join(s)
	s = s.replace('.', '0')
	print(s)


(n, p) = input().split()
(n, p) = (int(n), int(p))
ss = input()
s = list(ss)
sv = 0
for i in range(n - p):
	if s[i] != s[i + p] and s[i] != '.' and (s[i + p] != '.'):
		sv += 1
		break
	elif s[i] == '.' and s[i + p] != '.':
		if s[i + p] == '1':
			s[i] = '0'
		else:
			s[i] = '1'
		sv += 1
		break
	elif s[i] != '.' and s[i + p] == '.':
		if s[i] == '1':
			s[i + p] = '0'
		else:
			s[i + p] = '1'
		sv += 1
		break
	elif s[i] == s[i + p] and s[i] == '.':
		s[i] = '0'
		s[i + p] = '1'
		sv += 1
		break
f1 = ''.join(s)
f2 = f1.replace('.', '0')
if sv == 0:
	print('No')
else:
	print(f2)


def rev(s):
	if s == '1':
		return '0'
	else:
		return '1'
(n, p) = input().split(' ')
n = int(n)
p = int(p)
s = list(input())
b = False
if n >= 2 * p:
	for i in range(n):
		if s[i] == '.':
			if b == True:
				s[i] = '0'
				continue
			if i < p:
				if s[i + p] == '.':
					s[i] = '0'
					s[i + p] = '1'
				else:
					s[i] = rev(s[i + p])
			else:
				s[i] = rev(s[i - p])
			b = True
else:
	for i in range(n - p):
		if s[i] == '.':
			if b:
				s[i] = '0'
				continue
			elif s[i + p] == '.':
				s[i] = '0'
				s[i + p] = '1'
			else:
				s[i] = rev(s[i + p])
			b = True
		elif s[i + p] == '.':
			s[i + p] = rev(s[i])
			b = True
		elif s[i + p] != s[i]:
			b = True
	if b:
		for i in range(n - p, n):
			if s[i] == '.':
				s[i] = '0'
if b:
	print(''.join(s))
else:
	print('No')


(n, m) = map(int, input().split())
(l, r) = (list(input()), 'No')
for i in range(min(m, n - m)):
	d = {'0': 0, '1': 0, '.': 0}
	for j in range(i, n, m):
		d[l[j]] += 1
	(z, o, p) = (d[c] for c in '01.')
	if not (p or (z and o)):
		continue
	r = l
	if z and o:
		break
	t = ['0', '1'] if p > 1 else ['01'[not o]]
	while t:
		if l[i] == '.':
			l[i] = t.pop()
		i += m
	break
print(''.join(r).replace('.', '0'))


(n, p) = map(int, input().strip().split())
s = list(input())

def get(x):
	return '0' if x == '1' else '1'
for i in range(n - p):
	if s[i] == '.' and s[i + p] != '.':
		s[i] = get(s[i + p])
	elif s[i] != '.' and s[i + p] == '.':
		s[i + p] = get(s[i])
	elif s[i] == '.' and s[i + p] == '.':
		s[i] = '0'
		s[i + p] = '1'
for i in range(n):
	if s[i] == '.':
		s[i] = '0'
for i in range(n - p):
	if s[i] != s[i + p]:
		print(''.join(map(str, s)))
		exit(0)
print('No')


(n, p) = map(int, input().split())
s = list(map(str, input().strip()))
flag = 1
for i in range(n - p):
	if s[i] != '.' and s[i + p] != '.' and (s[i] == s[i + p]):
		continue
	else:
		flag = 0
		break
if flag == 1:
	print('NO')
else:
	for i in range(n - p):
		if s[i] == '.' and s[i + p] == '.':
			s[i] = '0'
			s[i + p] = '1'
		elif s[i] == '.':
			if s[i + p] == '1':
				s[i] = '0'
			else:
				s[i] = '1'
		elif s[i + p] == '.':
			if s[i] == '1':
				s[i + p] = '0'
			else:
				s[i + p] = '1'
	for i in range(n):
		if s[i] == '.':
			s[i] = '0'
	print(''.join(s))


(n, p) = map(int, input().split(' '))
s = input()
res = True

def op(c):
	return '1' if c == '0' else '0'

def out(s):
	print(s.replace('.', '0'))
	exit(0)
for i in range(n - p):
	j = i + p
	if s[i] == s[j] == '.':
		out(s[0:i] + '1' + s[i + 1:j] + '0' + s[j + 1:])
	if s[i] == '.':
		out(s[0:i] + op(s[j]) + s[i + 1:])
	if s[j] == '.':
		out(s[0:j] + op(s[i]) + s[j + 1:])
	if s[i] != s[j]:
		out(s)
print('No')


(n, p) = map(int, input().split())
s = input()
ans = True
ans2 = ['.'] * n
fl = False
for i in range(n):
	ans2[i] = s[i]
for i in range(n - p):
	if ans2[i] != '.' and ans2[i + p] == '.':
		if ans2[i] == '0':
			ans2[i + p] = '1'
		else:
			ans2[i + p] = '0'
		for j in range(len(ans2)):
			if ans2[j] == '.':
				ans2[j] = '0'
		fl = True
	elif ans2[i] == '.' and ans2[i + p] != '.':
		if ans2[i + p] == '0':
			ans2[i] = '1'
		else:
			ans2[i] = '0'
		for j in range(len(ans2)):
			if ans2[j] == '.':
				ans2[j] = '0'
		fl = True
	elif ans2[i] == '.' and ans2[i + p] == '.':
		ans2[i] = '1'
		ans2[i + p] = '0'
		for j in range(len(ans2)):
			if ans2[j] == '.':
				ans2[j] = '0'
		fl = True
	elif s[i] != s[i + p] and s[i] != '.' and (s[i + p] != '.'):
		fl = True
		for j in range(n):
			if ans2[j] == '.':
				ans2[j] = '0'
	if fl:
		break
if not fl:
	print('No')
else:
	for i in range(n):
		print(ans2[i], end='')


input_int = [int(x) for x in input().split()]
n = input_int[0]
p = input_int[1]
s = [x for x in input()]
period_str = {}
for i in range(p):
	period_str[i] = []
for i in range(len(s)):
	period_str[i % p].append(s[i])
for i in range(p):
	arr = period_str[i]
	if len(arr) == 1:
		continue
	for (ci, c) in enumerate(arr):
		if c == '.':
			for (di, d) in enumerate(arr):
				if ci == di:
					continue
				if d == '.' or d == '0':
					s[ci * p + i] = '1'
					s[di * p + i] = '0'
					for z in range(n):
						if s[z] == '.':
							s[z] = '1'
					print(''.join(s))
					exit(0)
				elif d == '1':
					s[di * p + i] = '1'
					s[ci * p + i] = '0'
					for z in range(n):
						if s[z] == '.':
							s[z] = '1'
					print(''.join(s))
					exit(0)
		else:
			for (di, d) in enumerate(arr):
				if ci == di:
					continue
				if c == d:
					continue
				if d == '.':
					if c == '1':
						s[di * p + i] = '0'
					else:
						s[di * p + i] = '1'
				for z in range(n):
					if s[z] == '.':
						s[z] = '1'
				print(''.join(s))
				exit(0)
print('No')


(n, p) = map(int, input().split())
a = [c for c in input()]
for i in range(n):
	if a[i] == '0':
		if i + p < n and a[i + p] == '.':
			a[i + p] = '1'
			break
	if a[i] == '1':
		if i + p < n and a[i + p] == '.':
			a[i + p] = '0'
			break
	if a[i] == '0':
		if i - p >= 0 and a[i - p] == '.':
			a[i - p] = '1'
			break
	if a[i] == '1':
		if i - p >= 0 and a[i - p] == '.':
			a[i - p] = '0'
			break
for i in range(n):
	if a[i] == '.':
		a[i] = ['0', '1'][i // p % 2]
ok = False
for i in range(n - p):
	if a[i] != a[i + p]:
		ok = True
if ok:
	print(''.join(a))
else:
	print('No')


(n, p) = input().split()
n = int(n)
p = int(p)
s = input()
ss = []
flag = 0
for i in range(0, len(s)):
	ss.append(s[i])
s = ss
for i in range(0, len(s) - p):
	if s[i + p] != '.' and s[i] != '.':
		if s[i] == '0' and s[i + p] == '0' or (s[i] == '1' and s[i + p] == '1'):
			continue
		else:
			flag = 1
	elif s[i] == '.' and s[i + p] == '.':
		s[i] = '0'
		s[i + p] = '1'
		flag = 1
	elif s[i] == '.':
		if s[i + p] == '0':
			s[i] = '1'
			flag = 1
		elif s[i + p] == '1':
			s[i] = '0'
			flag = 1
	elif s[i + p] == '.':
		if s[i] == '0':
			s[i + p] = '1'
			flag = 1
		elif s[i] == '1':
			s[i + p] = '0'
			flag = 1
	if flag == 1:
		for j in range(i, len(s)):
			if j == i or j == i + p:
				continue
			elif s[j] == '.':
				s[j] = '1'
		break
if flag == 1:
	print(''.join(s))
else:
	print('No')


(n, p) = [int(i) for i in input().split()]
s = list(input())
ok = 0
for i in range(n - p):
	if s[i] != '.' and s[i + p] != '.' and (s[i] != s[i + p]):
		ok = 1
		break
	elif s[i] == '.' or s[i + p] == '.':
		if s[i] == '1':
			s[i + p] = '0'
		elif s[i + p] != '0':
			s[i] = '0'
		ok = 1
		break
if ok:
	for i in s:
		print(i if i != '.' else '1', end='')
else:
	print('No')


(n, p) = map(int, input().split())
s = input()
t = None
j = p
for i in range(0, len(s) // p + 1):
	e = s[p * i:p * (i + 1)]
	if not t:
		t = e
	else:
		for (a, b) in zip(t, e):
			j += 1
			if a == b == '.':
				s = s.replace('.', '0')
				s = s[:j - 1] + '1' + s[j:]
				print(s)
				exit(0)
			if b == '.' and a != '.':
				s = s.replace('.', str(int(bool(int(a)))))
				s = s[:j - 1] + str(int(not bool(int(a)))) + s[j:]
				print(s)
				exit(0)
			elif a == '.' and b != '.':
				s = s.replace('.', str(int(bool(int(b)))))
				if j % p == 0:
					s = str(int(not bool(int(b)))) + s[j % p + 1:]
				else:
					s = s[:j % p - 1] + str(int(not bool(int(b)))) + s[j % p:]
				print(s)
				exit(0)
			elif a != b:
				print(s.replace('.', '0'))
				exit(0)
print('No')


(n, p) = map(int, input().split())
ans = False
s = list(input().strip())
length = len(s)
for i in range(length - p):
	if s[i] != '.':
		if s[i] == s[i + p]:
			v = 1
		else:
			ans = True
			if s[i + p] == '.':
				if s[i] == '0':
					s[i + p] = '1'
				else:
					s[i + p] = '0'
s = s[::-1]
for i in range(length - p):
	if s[i] != '.':
		if s[i] == s[i + p]:
			v = 1
		else:
			ans = True
			if s[i + p] == '.':
				if s[i] == '0':
					s[i + p] = '1'
				else:
					s[i + p] = '0'
s = s[::-1]
if '.' in s:
	if ans:
		for i in range(length):
			if s[i] == '.':
				s[i] = '0'
	else:
		for i in range(length):
			if s[i] == '.':
				s[i] = '0'
				ans = True
				if i + p < length:
					s[i + p] = '1'
ans = False
for i in range(length - p):
	if s[i] != s[i + p]:
		ans = True
if ans:
	print(''.join(s))
else:
	print('No')


(length, period) = map(int, input().split(' '))
row = [ch for ch in input()]
pairs = ((x, x + period) for x in range(0, length - period))
is_period = False
for (x, y) in pairs:
	if row[x] == '.' and row[y] == '.':
		row[x] = '1'
		row[y] = '0'
		break
	elif row[x] == '.':
		if row[y] == '1':
			row[x] = '0'
		else:
			row[x] = '1'
		break
	elif row[y] == '.':
		if row[x] == '1':
			row[y] = '0'
		else:
			row[y] = '1'
		break
	elif row[x] != row[y]:
		break
else:
	is_period = True
if is_period:
	print('No')
else:
	response = ''
	for ch in row:
		if ch == '.':
			response += '1'
		else:
			response += ch
	print(response)


(n, p) = map(int, input().split())
s = list(input())
L = len(s)
for i in range(L - p):
	if s[i] == s[i + p] and s[i] != '.':
		continue
	if s[i] == '.':
		if s[i + p] == '.':
			s[i] = '0'
			s[i + p] = '1'
		elif s[i + p] == '0':
			s[i] = '1'
		else:
			s[i] = '0'
	elif s[i] == '0' and s[i + p] == '.':
		s[i + p] = '1'
	elif s[i] == '1' and s[i + p] == '.':
		s[i + p] = '0'
	break
else:
	print('NO')
	exit()
for i in range(L):
	if s[i] == '.':
		s[i] = '0'
print(''.join(s))


(n, p) = map(int, input().split())
s = input()
l = list(s)
k = 0
a = 0
for i in range(len(s) - p):
	a = i
	if i + p > len(s) - 1:
		break
	if l[i] == l[i + p] and l[i] != '.':
		k += 1
	elif l[i] != l[i + p]:
		if l[i] == '.':
			for j in range(len(l)):
				if l[j] == '.':
					l[j] = '0'
			if l[i + p] == '0':
				l[i] = '1'
			else:
				l[i] = '0'
			print(''.join(l))
			break
		elif l[i + p] == '.':
			for j in range(len(l)):
				if l[j] == '.':
					l[j] = '0'
			if l[i] == '0':
				l[i + p] = '1'
			else:
				l[i + p] = '0'
			print(''.join(l))
			break
		else:
			for j in range(len(l)):
				if l[j] == '.':
					l[j] = '0'
			print(''.join(l))
			break
	elif l[i] == l[i + p] and l[i] == '.':
		for j in range(len(l)):
			if l[j] == '.':
				l[j] = '0'
		l[i] = '1'
		print(''.join(l))
		break
if k == a + 1:
	print('NO')
if p == n:
	print('NO')


(n, m) = map(int, input().split())
s = input()
flag = 1
for i in range(1, m + 1):
	s1 = ''
	(a, b, c) = (0, 0, 0)
	for j in range(-1 + i, n, m):
		if s[j] == '.':
			a += 1
		elif s[j] == '0':
			b += 1
		else:
			c += 1
	if not (a == 1 and b == 0 and (c == 0) or (a == 0 and (b == 0 or c == 0))):
		flag = 0
	for j in range(-1 + i, n, m):
		if s[j] == '.':
			if b == 0 and c == 0:
				s = s[:j] + '0' + s[j + 1:]
				b += 1
			elif b != 0:
				s = s[:j] + '1' + s[j + 1:]
			else:
				s = s[:j] + '0' + s[j + 1:]
if flag == 1:
	print('NO')
else:
	print(s)


(n, p) = map(int, input().split())
(*A,) = input()
d = 0
B = {'0': '1', '1': '0'}
for i in range(p):
	(*Z,) = A[i::p]
	for j in range(len(Z)):
		if Z[j] != '.':
			break
	if Z[j] == '.':
		Z[j] = '0'
	r = 0
	for k in range(len(Z)):
		if j != k:
			if Z[k] == '.' or Z[k] != Z[j]:
				Z[k] = B[Z[j]]
				r = 1
			else:
				Z[k] = Z[j]
	if len(Z) != 1:
		d += r
	A[i::p] = Z
if d:
	print(''.join(A))
else:
	print('No')


str1 = list(map(int, input().split()))
n = str1[0]
p = str1[1]
s = input()
cor = dict()
flag = False
for i in range(n - p):
	if s[i] != '.' and s[i + p] != '.':
		if s[i] == s[i + p]:
			continue
		else:
			flag = True
			break
	elif s[i] == '.' and s[i + p] != '.':
		cor[i] = str((int(s[i + p]) + 1) % 2)
		flag = True
		break
	elif s[i] != '.' and s[i + p] == '.':
		cor[i + p] = str((int(s[i]) + 1) % 2)
		flag = True
		break
	elif s[i] == '.' and s[i + p] == '.':
		cor[i] = '0'
		cor[i + p] = '1'
		flag = True
		break
ans = []
if flag:
	for i in range(n):
		if s[i] != '.':
			ans.append(s[i])
		elif cor.get(i, '-1') != '-1':
			ans.append(cor.get(i))
		else:
			ans.append('0')
	print(''.join(ans))
else:
	print('No')


(s, p) = [int(x) for x in input().split()]
x = list(input())
done = False
for l in range(0, s - p):
	if x[l] != x[l + p]:
		done = True
		if x[l] == '.':
			x[l] = str(1 - int(x[l + p]))
		else:
			x[l + p] = str(1 - int(x[l]))
	if x[l] == '.' and x[l + p] == '.':
		done = True
		(x[l], x[l + p]) = ('0', '1')
for g in range(s - p, p):
	if x[g] == '.':
		x[g] = '0'
if done:
	print(''.join(x))
else:
	print('No')


(n, k) = [int(n) for n in input().split()]
s = input()
arr = list(s)
flag = 0
i = 0
j = k
while j < n:
	if arr[i] != '.' and arr[j] != '.':
		if int(arr[i]) + int(arr[j]) == 1:
			flag = 1
			break
		i = i + 1
		j = j + 1
		continue
	if arr[i] == '.' and arr[j] == '.':
		arr[i] = '0'
		arr[j] = '1'
		flag = 1
		break
	if arr[i] != '.' and arr[j] == '.':
		arr[j] = str(1 - int(arr[i]))
		flag = 1
		break
	if arr[j] != '.' and arr[i] == '.':
		arr[i] = str(1 - int(arr[j]))
		flag = 1
		break
if flag == 0:
	print('No')
else:
	for i in range(n):
		if arr[i] == '.':
			arr[i] = '0'
	s = ''.join(arr)
	print(s)


(n, p) = map(int, input().split())
s = input()
for i in range(n - p):
	(x, y) = (s[i], s[i + p])
	if '.' in (x, y) or x != y:
		a = list(s.replace('.', '1'))
		if x == y and x == '.':
			a[i] = '1'
			a[i + p] = '0'
			print(''.join(a))
		elif x == '.':
			a[i] = str(int(y) ^ 1)
			print(''.join(a))
		elif y == '.':
			a[i + p] = str(int(x) ^ 1)
			print(''.join(a))
		else:
			print(''.join(a))
		exit()
print('No')


(n, p) = [int(i) for i in input().split()]
tides = input()

def is_periodic():
	for i in range(n - p):
		if tides[i] != tides[i + p]:
			return False
	return True

def main():
	if n == p:
		print('No')
		return
	ldot = tides.find('.')
	rdot = tides.rfind('.')
	tideslist = list(tides)
	if ldot + p < n:
		dot = ldot
		notdot = ldot + p
	elif rdot - p >= 0:
		dot = rdot
		notdot = rdot - p
	else:
		if is_periodic():
			print('No')
		else:
			print(tides.replace('.', '0'))
		return
	if tides[notdot] == '.':
		tideslist[notdot] = '0'
		tideslist[dot] = '1'
	elif tides[notdot] == '0':
		tideslist[dot] = '1'
	elif tides[notdot] == '1':
		tideslist[dot] = '0'
	else:
		raise Exception()
	print(''.join(tideslist).replace('.', '0'))
main()


(n, k) = map(int, input().split())
ss = input()
s = []
for i in ss:
	s.append(i)
f = 0
for i in range(n - k):
	if s[i] == '.':
		f = 1
		if s[i + k] == '.':
			s[i] = '0'
			s[i + k] = '1'
		elif s[i + k] == '0':
			s[i] = '1'
		elif s[i + k] == '1':
			s[i] = '0'
		break
	elif s[i] == '0':
		if s[i + k] == '.':
			f = 1
			s[i + k] = '1'
			break
		elif s[i + k] == '1':
			f = 1
			break
	elif s[i] == '1':
		if s[i + k] == '.':
			f = 1
			s[i + k] = '0'
			break
		elif s[i + k] == '0':
			f = 1
			break
for i in range(n):
	if s[i] == '.':
		s[i] = '0'
a = ''
for i in s:
	a = a + str(i)
if f:
	print(a)
else:
	print('No')


(n, p) = map(int, input().split())
u = list(input())

def loop(k):
	global u
	for i in range(k, p + k):
		if i + p < n:
			if u[i] == '.':
				if u[i + p] == '.':
					u[i] = '0'
					u[i + p] = '1'
				elif u[i + p] == '0':
					u[i] = '1'
				else:
					u[i] = '0'
				return True
			elif u[i + p] == '.':
				if u[i] == '.':
					u[i] = '0'
					u[i + p] = '1'
				elif u[i] == '0':
					u[i + p] = '1'
				else:
					u[i + p] = '0'
				return True
			elif u[i] != u[i + p]:
				return True
	return False
ok = False
for i in range(n // p):
	ok = loop(i * p)
	if ok:
		break
if not ok:
	import sys
	print('No')
	sys.exit()
for i in u:
	if i == '.':
		print(0, end='')
	else:
		print(i, end='')


(n, p) = map(int, input().strip().split())
import random

def conv(ch):
	if ch == '.':
		return -1
	else:
		return int(ch)

def _str(s):
	new_str = ''
	for i in range(len(s)):
		if s[i] == '.':
			new_str += str(random.randint(0, 1))
		else:
			new_str += s[i]
	return new_str
if n == p:
	print('No')
else:
	st = input()
	vec = st[:p]
	i = 0
	for j in range(p, n):
		if j % p == 0:
			i = 0
		num2 = conv(st[j])
		num1 = conv(vec[i])
		if num1 == -1 or num2 == -1 or num1 ^ num2:
			if num1 == -1 and num2 == -1:
				new_str = st[:i] + '0' + st[i + 1:j] + '1' + st[j + 1:]
			elif num1 == -1:
				if num2 == 1:
					new_str = st[:i] + '0' + st[i + 1:]
				else:
					new_str = st[:i] + '1' + st[i + 1:]
			elif num2 == -1:
				if num1 == 1:
					new_str = st[:j] + '0' + st[j + 1:]
				else:
					new_str = st[:j] + '1' + st[j + 1:]
			else:
				new_str = st
			print(_str(new_str))
			break
		i += 1
	else:
		print('No')


(n, p) = map(int, input().split())
s = list(input())
ans = 0
for i in range(p):
	if i + p > n - 1 and s[i] == '.':
		s[i] = '1'
	elif s[i] == '.' and s[i + p] == '.':
		s[i] = '1'
	elif s[i] == '.':
		if s[i + p] == '1':
			s[i] = '0'
		else:
			s[i] = '1'
for i in range(p):
	temp = 0
	for j in range(i + p, n, p):
		if s[j - p] != s[j]:
			temp = 1
		if s[j] == '.':
			temp = 1
			if s[j - p] == '1':
				s[j] = '0'
			else:
				s[j] = '1'
	if temp == 1:
		ans = 1
if ans == 0:
	print('No')
else:
	print(''.join(s))


from collections import Counter
(n, p) = map(int, input().split())
s = list(input())
waves = {}
flag = True
for i in range(n):
	if s[i] == '.':
		c_v = waves.get(i % p, 0)
		if c_v == '-1':
			flag = False
			break
		elif c_v == 0:
			waves[i % p] = '-1'
		else:
			flag = False
			break
	elif s[i] != '.':
		c_v = waves.get(i % p, 0)
		if c_v == '-1':
			waves[i % p] = s[i]
			flag = False
			break
		elif c_v == 0:
			waves[i % p] = s[i]
		elif c_v != s[i]:
			flag = False
			break
for i in range(n):
	if s[i] == '.':
		if waves.get(i % p, 0) in [0, '-1']:
			s[i] = '0'
			waves[i % p] = '0'
		else:
			s[i] = str(1 - int(waves[i % p]))
			flag = False
if not flag:
	print(*s, sep='')
else:
	print('No')


import re
import math
import decimal
import bisect

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

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

def viread():
	return [int(x) for x in input().strip().split()]
(n, p) = viread()
line = read()
for (i, c) in enumerate(line):
	try:
		if c != '.' and (line[i + p] == '.' or line[i + p] != c):
			notc = ('0' if c == '1' else '1').encode()[0]
			newline = bytearray(line.encode())
			if line[i + p] == '.':
				newline[i + p] = notc
			toprint = re.sub('\\.', '0', newline.decode())
			print(toprint)
			exit(0)
		elif line[i + p] != '.' and (c == '.' or c != line[i + p]):
			notc = ('0' if line[i + p] == '1' else '1').encode()[0]
			newline = bytearray(line.encode())
			if c == '.':
				newline[i] = notc
			toprint = re.sub('\\.', '0', newline.decode())
			print(toprint)
			exit(0)
		elif c == '.' and line[i + p] == '.':
			newline = bytearray(line.encode())
			newline[i] = b'1'[0]
			newline[i + p] = b'0'[0]
			toprint = re.sub('\\.', '0', newline.decode())
			print(toprint)
			exit(0)
	except IndexError:
		break
print('No')


(n, p) = map(int, input().split())
s = input()
ans = s.replace('.', '0')
if all((ans[i] == ans[i + p] for i in range(n - p))):
	i = 0
	while i < n and s[i] != '.':
		i += 1
	if i + p < n:
		ans = ans[:i] + '1' + ans[i + 1:]
		print(ans)
		exit()
	i = n - 1
	while i >= 0 and s[i] != '.':
		i -= 1
	if i - p >= 0:
		ans = ans[:i] + '1' + ans[i + 1:]
		print(ans)
		exit()
	print('No')
else:
	print(ans)


(n, p) = map(int, input().split())
s = list(input())
for i in range(n - p):
	if s[i] != '.' and s[i + p] != '.' and (s[i] == s[i + p]):
		pass
	elif s[i] != '.' and s[i + p] == '.':
		s[i + p] = '0' if s[i] == '1' else '1'
	elif s[i] == '.' and s[i + p] != '.':
		s[i] = '0' if s[i + p] == '1' else '1'
	else:
		j = i
		while j < n and s[j] == '.':
			j += p
		if j >= n:
			j = i + p
			s[i] = '1'
			while j < n:
				s[j] = '0' if s[j - p] == '1' else '1'
				j += p
		else:
			while i + p <= j:
				s[j - p] = '0' if s[j] == '1' else '1'
				j -= p
for i in range(n):
	if s[i] == '.':
		s[i] = '1'
ans = False
for i in range(n - p):
	if s[i] != s[i + p]:
		ans = True
		break
print(''.join(s) if ans else 'No')


IN = input().split()
W = input()
n = int(IN[0])
p = int(IN[1])
S = [0] * n
ans = 0
for i in range(0, n):
	if W[i] == '.':
		S[i] = -1
	else:
		S[i] = int(W[i])
for i in range(0, n - p):
	if S[i] == -1:
		ans = 1
		if S[i + p] == -1:
			S[i] = 0
			S[i + p] = 1
		elif S[i + p] == 1:
			S[i] = 0
		else:
			S[i] = 1
		break
	elif S[i] != S[i + p]:
		ans = 1
		if S[i] == 1:
			S[i + p] = 0
		else:
			S[i + p] = 1
		break
if ans == 0:
	print('No')
else:
	for i in range(0, n):
		if S[i] == -1:
			S[i] = 1
		print(S[i], end='')


(n, m) = [int(i) for i in input().split()]
s = str(input())
e = 0
for i in range(0, len(s) - m):
	if s[i] == s[i + m]:
		if s[i] != '.':
			e = e + 1
if e == n - m:
	print('NO')
else:
	s = list(s)
	for j in range(0, len(s) - m):
		if s[j] == s[j + m]:
			if s[j] == '.':
				s[j] = '1'
				s[j + m] = '0'
			else:
				pass
		elif s[j] == '.':
			if s[j + m] == '1':
				s[j] = '0'
			else:
				s[j] = '1'
		elif s[j + m] == '.':
			if s[j] == '1':
				s[j + m] = '0'
			else:
				s[j + m] = '1'
		else:
			pass
	for j in range(0, len(s)):
		if s[j] == '.':
			s[j] = '1'
	print(''.join(s))


(n, p) = [int(x) for x in input().strip().split(' ')]
a = list(input().strip())
flag = False
for i in range(0, n - p):
	if a[i] == a[i + p] and a[i] != '.':
		continue
	if a[i] == '.':
		if a[i + p] == '.':
			a[i] = '0'
			a[i + p] = '1'
		elif a[i + p] == '0':
			a[i] = '1'
		else:
			a[i] = '0'
	elif a[i + p] == '.':
		if a[i] == '0':
			a[i + p] = '1'
		else:
			a[i + p] = '0'
	flag = True
	break
if flag:
	for i in range(n):
		if a[i] == '.':
			a[i] = '1'
	print(''.join(a))
else:
	print('No')


k = input().split()
n = int(k[0])
p = int(k[1])
s = input()
s = list(s)
counter = 0
for i in range(n - p):
	tec = s[i]
	next = s[i + p]
	if tec == '.':
		if next == '.':
			s[i] = '1'
			s[i + p] = '0'
			counter = 1
		elif next == '1':
			s[i] = '0'
			counter = 1
		elif next == '0':
			s[i] = '1'
			counter = 1
	elif tec == '1':
		if next == '.':
			s[i + p] = '0'
			counter = 1
		elif next == '0':
			counter = 1
	elif tec == '0':
		if next == '.':
			s[i + p] = '1'
			counter = 1
		elif next == '1':
			counter = 1
	if counter == 1:
		break
if counter == 0:
	print('No')
else:
	l = ''
	for i in s:
		l += i
	p = l.replace('.', '1')
	print(p)


(n, p) = map(int, input().split())
s = list(input())
i = next((i for (i, (x, y)) in enumerate(zip(s, s[p:])) if not x == y != '.'), -1)
if i < 0:
	print('No')
else:
	if s[i] == '.':
		s[i] = '01'[s[i + p] in '.0']
	if s[i + p] == '.':
		s[i + p] = '01'[s[i] == '0']
	print(''.join(s).replace('.', '0'))


import os
import sys
import math
(n, p) = input().strip().split(' ')
(n, p) = [int(n), int(p)]
s = str(input())
c = []
for x in range(0, len(s)):
	if s[x] == '.':
		c.append(-1)
	else:
		c.append(int(s[x]))
i = 0
while i + p < len(c):
	if c[i] == -1 and c[i + p] != -1:
		if c[i + p] == 1:
			c[i] = 0
		elif c[i + p] == 0:
			c[i] = 1
	elif c[i] != -1 and c[i + p] == -1:
		if c[i] == 1:
			c[i + p] = 0
		elif c[i] == 0:
			c[i + p] = 1
	elif c[i] == -1 and c[i + p] == -1:
		c[i] = 0
		c[i + p] = 1
	i += 1
for x in range(0, len(c)):
	if c[x] == -1:
		c[x] = 0
count = 0
for x in range(0, len(c) - p):
	if c[x] != c[x + p]:
		count += 1
if count > 0:
	print(''.join((str(c[x]) for x in range(0, len(c)))))
else:
	print('No')


(n, p) = map(int, input().split(' '))
string = [i for i in input()]
for i in range(n):
	if string[i] == '.':
		string[i] = 2
	else:
		string[i] = int(string[i])
possible = False
for i in range(n - p):
	if string[i] != string[i + p] and string[i] != 2 and (string[i + p] != 2):
		possible = True
		break
	elif string[i] == 2 and string[i + p] != 2:
		string[i] = 1 - string[i + p]
		possible = True
		break
	elif string[i] == 2 and string[i + p] == 2:
		string[i] = 1
		string[i + p] = 0
		possible = True
		break
	elif string[i] != 2 and string[i + p] == 2:
		string[i + p] = 1 - string[i]
		possible = True
		break
for i in range(n):
	if string[i] == 2:
		string[i] = 0
if possible:
	print(*string, sep='')
else:
	print('No')


(n, p) = map(int, input().split())
s = list(input().strip())
f = True
for i in range(p):
	k = s[i]
	if k != '.':
		for j in range(i + p, n, p):
			if s[j] == '.':
				s[j] = str((int(k) + 1) % 2)
			if s[j] != k:
				f = False
	else:
		for j in range(i, n, p):
			if s[j] != '.':
				k = s[j]
		if k == '.':
			k = '1'
			s[i] = k
		else:
			s[i] = str((int(k) + 1) % 2)
			f = False
		for j in range(i + p, n, p):
			if s[j] == '.':
				s[j] = str((int(k) + 1) % 2)
			if s[j] != k:
				f = False
if f:
	print('No')
else:
	print(*s, sep='')


k = input().strip().split(' ')
n = int(k[0])
p = int(k[1])
l = [i for i in input()]
i = 0
j = i + p
ans = 1
while i < n and j < n:
	if l[i] == '0' and l[j] == '0':
		w = 2
	elif l[i] == '1' and l[j] == '1':
		s = 0
	else:
		ans = 0
		break
	i += 1
	j += 1
if ans == 1:
	print('No')
else:
	if l[i] == '.' and l[j] == '1':
		l[i] = '0'
	elif l[j] == '.' and l[i] == '1':
		l[j] = '0'
	elif l[i] == '.' and l[j] == '0':
		l[i] = '1'
	elif l[j] == '.' and l[i] == '0':
		l[j] = '1'
	elif l[i] == '.' and l[j] == '.':
		l[i] = '0'
		l[j] = '1'
	for k in range(len(l)):
		if l[k] == '.':
			l[k] = '0'
		print(l[k], end='')


(n, p) = map(int, input().split(' '))
s = input()
a = list(s)
count = 0
for i in range(0, len(a) - p):
	if a[i] != '.' and a[i + p] != '.':
		if a[i] == a[i + p]:
			continue
		else:
			count = 1
			break
	else:
		if a[i] == '.':
			if a[i + p] == '0':
				a[i] = '1'
			elif a[i + p] == '1':
				a[i] = '0'
		elif a[i + p] == '.':
			if a[i] == '0':
				a[i + p] = '1'
			elif a[i] == '1':
				a[i + p] = '0'
		if a[i + p] == '.' and a[i] == '.':
			a[i] = '0'
			a[i + p] = '1'
		count = 1
if count == 1:
	for i in range(0, n):
		if a[i] == '.':
			a[i] = '0'
if count == 1:
	a = ''.join(a)
	print(a)
else:
	print('No')


(n, m) = input().split()
n = int(n)
m = int(m)
str1 = input()
d = n - m
str2 = ['-1'] * n
c = 0
for i in range(d):
	if str1[i] == '.' and str1[i + m] != '.':
		if str1[i + m] == '1':
			str2[i] = '0'
			str2[i + m] = '1'
		else:
			str2[i] = '1'
			str2[i + m] = '0'
	elif str1[i] != '.' and str1[i + m] == '.':
		if str1[i] == '1':
			str2[i] = '1'
			str2[i + m] = '0'
		else:
			str2[i] = '0'
			str2[i + m] = '1'
	elif str1[i] != '.' and str1[i + m] != '.':
		if str1[i] == str1[i + m]:
			c += 1
		str2[i] = str1[i]
		str2[i + m] = str1[i + m]
	else:
		str2[i] = '1'
		str2[i + m] = '0'
if c == d:
	print('No')
	exit()
for i in range(d, m):
	if str1[i] == '.':
		str2[i] = '1'
	else:
		str2[i] = str1[i]
for i in str2:
	print(i, end='')


(n, p) = map(int, input().split())
s = input()
ls = [[] for i in range(p)]
for i in range(n):
	ls[i % p].append(s[i])
ans_given = False
for i in range(p):
	if ls[i].count('0') >= 1 and ls[i].count('1') >= 1:
		for j in range(n):
			if s[j] == '.':
				print('0', end='')
			else:
				print(s[j], end='')
		ans_given = True
		break
	elif ls[i].count('.') >= 2:
		flag = True
		for j in range(n):
			if s[j] == '.':
				if flag and j % p == i:
					print('1', end='')
					flag = False
				else:
					print('0', end='')
			else:
				print(s[j], end='')
		ans_given = True
		break
	elif ls[i].count('.') == 1:
		if ls[i].count('0') >= 1:
			for j in range(n):
				if s[j] == '.':
					if j % p == i:
						print('1', end='')
					else:
						print('0', end='')
				else:
					print(s[j], end='')
			ans_given = True
			break
		elif ls[i].count('1') >= 1:
			for j in range(n):
				if s[j] == '.':
					print('0', end='')
				else:
					print(s[j], end='')
			ans_given = True
			break
if ans_given == False:
	print('No')


(n, p) = [int(i) for i in input().split()]
s = list(input())
i = 0
j = p
c = 0
while j != n:
	if s[i] != s[j]:
		if s[i] == '.' and s[j] == '1':
			s[i] = '0'
		elif s[i] == '.' and s[j] == '0':
			s[i] = '1'
		elif s[j] == '.' and s[i] == '1':
			s[j] = '0'
		elif s[j] == '.' and s[i] == '0':
			s[j] = '1'
		c = 1
	elif s[i] == '.' and s[j] == '.':
		s[i] = '0'
		s[j] = '1'
		c = 1
	i += 1
	j += 1
if c:
	for i in range(i, j):
		if s[i] == '.':
			s[i] = '0'
	for item in s:
		print(item, end='')
else:
	print('No')


numbers1 = input().split(' ')
n = int(numbers1[0])
p = int(numbers1[1])
sir = list(input())
ya = False
for i in range(len(sir) - p):
	if (sir[i] != sir[i + p] or (sir[i] == '.' and sir[i + p] == '.')) and (not ya):
		ya = True
		if sir[i] == '.':
			if sir[i + p] == '.':
				sir[i] = '0'
				sir[i + p] = '1'
			elif sir[i + p] == '1':
				sir[i] = '0'
			else:
				sir[i] = '1'
		elif sir[i + p] == '.':
			if sir[i] == '1':
				sir[i + p] = '0'
			else:
				sir[i + p] = '1'
if ya:
	for i in range(len(sir)):
		if sir[i] == '.':
			sir[i] = '0'
	sir = ','.join(sir)
	sir = sir.replace(',', '')
	print(sir)
else:
	print('No')


(n, p) = map(int, input().split())
s = list(input())
f = True
for i in range(n):
	if s[i] == '.':
		if i + p < n:
			if s[i + p] == '0':
				s[i] = '1'
			else:
				s[i] = '0'
		elif i >= p:
			if s[i - p] == '0':
				s[i] = '1'
			else:
				s[i] = '0'
		else:
			s[i] = '0'
for i in range(n - p):
	if s[i] != s[i + p]:
		f = False
if f:
	print('No')
else:
	print(''.join(s))


def sv():
	(N, P) = map(int, input().split())
	S = list(input())
	res = False
	for n in range(N):
		if S[n] == '.':
			S[n] = '0'
			if n - P >= 0 and S[n - P] == '0' or (n + P < N and S[n + P] == '0'):
				S[n] = '1'
		if n - P >= 0 and S[n - P] != S[n]:
			res = True
	return ''.join(S) if res else 'No'
print(sv())


from sys import stdin, stdout

def rint():
	return map(int, stdin.readline().split())
(n, p) = rint()
s = input()
s = list(s)
flag = 0
for i in range(n - p):
	j = i + p
	if s[i] == s[j] and s[i] != '.':
		pass
	else:
		flag = 1
if flag == 0:
	print('No')
	exit()
for i in range(n - p):
	j = i + p
	if s[i] == s[j] and s[i] == '.':
		for k in range(n):
			if k == i:
				s[k] = '1'
			elif k == j:
				s[k] = '0'
			elif s[k] == '.':
				s[k] = '1'
		print(''.join(s))
		exit()
	if s[i] != s[j]:
		if s[i] == '.':
			if s[j] == '0':
				s[i] = '1'
			else:
				s[i] = '0'
		if s[j] == '.':
			if s[i] == '0':
				s[j] = '1'
			else:
				s[j] = '0'
		for k in range(n):
			if s[k] == '.':
				s[k] = '1'
		print(''.join(s))
		exit()


(n, p) = map(int, input().split())
s = str(input())
i = 0
flag = 0
while i + p < len(s):
	if s[i] == s[i + p] and s[i] != '.':
		pass
	elif s[i] == s[i + p] and s[i] == '.':
		if i + p == len(s) - 1:
			s = s[:i] + '1' + s[i + 1:i + p] + '0'
		else:
			s = s[:i] + '1' + s[i + 1:i + p] + '0' + s[i + p + 1:]
		flag = 1
		break
	elif s[i] != s[i + p] and s[i] != '.' and (s[i + p] != '.'):
		flag = 1
		break
	elif s[i] != s[i + p]:
		if s[i] == '.':
			if s[i + p] == '0':
				s = s[:i] + '1' + s[i + 1:]
			else:
				s = s[:i] + '0' + s[i + 1:]
		elif s[i] == '0':
			if i + p == len(s) - 1:
				s = s[:i + p] + '1'
			else:
				s = s[:i + p] + '1' + s[i + p + 1:]
		elif i + p == len(s) - 1:
			s = s[:i + p] + '0'
		else:
			s = s[:i + p] + '0' + s[i + p + 1:]
		flag = 1
	i += 1
if flag == 0:
	print('No')
else:
	for i in range(len(s) - 1):
		if s[i] == '.':
			s = s[:i] + '0' + s[i + 1:]
	if s[-1] == '.':
		s = s[:-1] + '0'
	print(s)


(n, p) = map(int, input().split())
s = list(input())
flag = 1
for i in range(len(s) - p):
	if s[i] != s[i + p]:
		flag = 0
		break
test = list(set(s))
if flag == 1:
	for i in range(len(s) - p):
		if s[i] == '.' and s[i + p] == '.':
			s[i] = '0'
			s[i + p] = '1'
		elif s[i] == '.' and s[i + p] == '0':
			s[i] = '1'
		elif s[i] == '.' and s[i + p] == '1':
			s[i] = '0'
		elif s[i] == '0' and s[i + p] == '.':
			s[i + p] = '1'
		elif s[i] == '1' and s[i + p] == '.':
			s[i + p] = '0'
	for i in range(len(s)):
		if s[i] == '.':
			s[i] = '1'
	flag1 = 1
	for i in range(len(s) - p):
		if s[i] != s[i + p]:
			flag1 = 0
			break
	if flag1 == 1:
		print('No')
	else:
		print(''.join(s))
elif flag == 0:
	for i in range(len(s) - p):
		if s[i] == '0' and s[i + p] == '.':
			s[i + p] = '1'
		elif s[i] == '1' and s[i + p] == '.':
			s[i + p] = '0'
		elif s[i] == '.' and s[i + p] == '0':
			s[i] = '1'
		elif s[i] == '.' and s[i + p] == '1':
			s[i] = '0'
	for i in range(len(s)):
		if s[i] == '.':
			s[i] = '0'
	print(''.join(s))


(n, p) = input().split()
n = int(n)
p = int(p)
s = input()
a = ['1' if x == '.' else x for x in s]
b = ['0' if x == '.' else x for x in s]
h = 0
for i in range(n):
	if i + p >= n:
		break
	if s[i] == '.' and s[i + p] == '.':
		a[i] = '1'
		a[i + p] = '0'
		h = 1
	elif s[i] == '.':
		a[i] = str(1 - int(s[i + p]))
		h = 1
	elif s[i + p] == '.':
		a[i + p] = str(1 - int(s[i]))
		h = 1
	elif a[i] != a[i + p]:
		h = 1
	elif b[i] != b[i + p]:
		h = 2
if h == 2:
	print(''.join(b))
else:
	print(''.join(a)) if h else print('No')


def main():
	(n, p) = map(int, input().split())
	s = list(input())
	no = True
	for i in range(n - p):
		if s[i] == '.' and s[i + p] == '.':
			s[i] = '1'
			s[i + p] = '0'
			no = False
			break
		elif s[i] == '.':
			s[i] = '1' if s[i + p] == '0' else '0'
			no = False
			break
		elif s[i + p] == '.':
			s[i + p] = '1' if s[i] == '0' else '0'
			no = False
			break
		elif s[i] != s[i + p]:
			no = False
			break
	if not no:
		s = ''.join(s).replace('.', '0')
		print(s)
	else:
		print('No')
main()


def fun(x, p):
	for i in range(len(x)):
		if i >= p and i <= len(x) - p:
			if x[i] != x[i + p]:
				return [i, i + p]
			elif x[i] == x[i + p] == '.':
				return [i, i + p]
			elif x[i] != x[i - p]:
				return [i, i - p]
			elif x[i] == x[i - p] == '.':
				return [i, i - p]
		elif i >= p:
			if x[i] != x[i - p]:
				return [i, i - p]
			elif x[i] == x[i - p] == '.':
				return [i, i - p]
		elif i < len(x) - p:
			if x[i] != x[i + p]:
				return [i, i + p]
			elif x[i] == x[i + p] == '.':
				return [i, i + p]
	return 0
(n, p) = map(int, input().split())
x = list(input())
if fun(x, p) == 0:
	print('No')
else:
	ll = fun(x, p)
	i = ll[0]
	j = ll[1]
	if x[i] == '1' and x[j] == '0':
		for t in x:
			if t == '.':
				print('1', end='')
			else:
				print(t, end='')
	elif x[i] == '0' and x[j] == '1':
		for t in x:
			if t == '.':
				print('1', end='')
			else:
				print(t, end='')
	elif x[i] == '.' and x[j] == '1':
		for t in range(len(x)):
			if i == t:
				print('0', end='')
			elif x[t] == '.':
				print('1', end='')
			else:
				print(x[t], end='')
	elif x[i] == '.' and x[j] == '0':
		for t in range(len(x)):
			if i == t:
				print('1', end='')
			elif x[t] == '.':
				print('1', end='')
			else:
				print(x[t], end='')
	elif x[j] == '.' and x[i] == '1':
		for t in range(len(x)):
			if j == t:
				print('0', end='')
			elif x[t] == '.':
				print('1', end='')
			else:
				print(x[t], end='')
	elif x[j] == '.' and x[i] == '0':
		for t in range(len(x)):
			if j == t:
				print('1', end='')
			elif x[t] == '.':
				print('1', end='')
			else:
				print(x[t], end='')
	elif x[i] == '.' and x[j] == '.':
		for t in range(len(x)):
			if j == t:
				print('1', end='')
			elif i == t:
				print('0', end='')
			elif x[t] == '.':
				print('1', end='')
			else:
				print(x[t], end='')


TN = 1

def solution():
	(n, p) = map(int, input().split())
	s = list(input())
	ind = []
	f = 1
	for i in range(len(s) - p):
		if s[i] == s[i + p] and s[i] == '.':
			s[i] = '0'
			s[i + p] = '1'
			f = 0
			break
		elif s[i] != s[i + p]:
			if s[i] == '.':
				if s[i + p] == '0':
					s[i] = '1'
				else:
					s[i] = '0'
			elif s[i + p] == '.':
				if s[i] == '0':
					s[i + p] = '1'
				else:
					s[i + p] = '0'
			f = 0
			break
	if f:
		print('No')
	else:
		for i in range(len(s)):
			if s[i] == '.':
				s[i] = '0'
		print(''.join(s))
while TN != 0:
	solution()
	TN -= 1


(n, p) = map(int, input().split())
a = list(input())
flag = 0
for i in range(n - p):
	if '.' in [a[i], a[i + p]]:
		if a[i] == '.' and a[i + p] == '.':
			a[i] = '1'
			a[i + p] = '0'
		elif a[i] == '.':
			if a[i + p] == '0':
				a[i] = '1'
			else:
				a[i] = '0'
		elif a[i] == '0':
			a[i + p] = '1'
		else:
			a[i + p] = '0'
flag = 0
for i in range(n - p):
	if a[i] != a[i + p]:
		flag = 1
		break
if not flag:
	print('No')
else:
	for i in range(n):
		if a[i] == '.':
			a[i] = '0'
	print(''.join(a))


s = input()
(n, p) = map(int, s.split())
s = input()
result = list(s)
import sys
for k in range(n - p):
	curr = s[k]
	toFlip = curr == '.'
	for j in range(k + p, n, p):
		if s[j] == '.':
			toPrint = True
			if curr == '.':
				result[j] = '1'
				result[k] = '.'
			elif curr == '1':
				result[j] = '0'
			else:
				result[j] = '1'
		elif toFlip:
			toPrint = True
			if s[j] == '0':
				result[k] = '1'
			else:
				result[k] = '0'
		elif curr != s[j]:
			print(s.replace('.', '0'))
			sys.exit(0)
		else:
			continue
		if toPrint:
			for idx in range(len(result)):
				if result[idx] == '.':
					result[idx] = '0'
			print(''.join(result))
			sys.exit(0)
print('No')


(n, p) = map(int, input().split())
s = list(input())
ok = False
for i in range(0, n - p):
	if s[i] == '.' and s[i + p] == '.':
		s[i] = '1'
		s[i + p] = '0'
	if s[i] == '.':
		s[i] = str(1 - int(s[i + p]))
	if s[i + p] == '.':
		s[i + p] = str(1 - int(s[i]))
	if s[i] != s[i + p]:
		ok = True
print(''.join(s).replace('.', '1') if ok else 'No')


(n, k) = list(map(int, input().split()))
s = input()
t = True
for i in range(n - k):
	if s[i] != s[i + k] or s[i] == '.' or s[i + k] == '.':
		t = False
		if s[i] == '.' and s[i + k] == '.' or s[i + k] == '0':
			s = s[0:i] + '1' + s[i + 1:]
		if s[i] == '0':
			s = s[0:i + k] + '1' + s[i + k + 1:]
		break
if t:
	print('No')
else:
	while '.' in s:
		s = s.replace('.', '0')
	print(s)


(n, p) = map(int, input().split())
s = list(input())
cnt = 0
ans = 1
for i in range(n - p):
	if s[i] == '1' and s[i + p] == '.':
		s[i + p] = '0'
		cnt += 1
	elif s[i] == '0' and s[i + p] == '.':
		s[i + p] = '1'
		cnt += 1
	elif s[i] == '.' and s[i + p] == '1':
		s[i] = '0'
		cnt += 1
	elif s[i] == '.' and s[i + p] == '0':
		s[i] = '1'
		cnt += 1
	elif s[i] == '.' and s[i + p] == '.':
		s[i] = '1'
		s[i + p] = '0'
		cnt += 1
if cnt > 0:
	for i in range(len(s)):
		if s[i] == '.':
			s[i] = '0'
else:
	flag = True
	for i in range(n - p):
		if s[i] != '.' and s[i + p] != '.' and (s[i] != s[i + p]):
			flag = False
	if flag == False:
		for i in range(n):
			if s[i] == '.':
				s[i] = '0'
	else:
		ans = 0
if ans == 0:
	print('No')
else:
	for m in s:
		print(m, end='')


(n, p) = map(int, input().split())
s = str(input())
a = list(s)
for i in range(n - p):
	if s[i] != s[i + p] or (s[i] == s[i + p] and s[i] == '.'):
		if s[i] == s[i + p] and s[i] == '.':
			a[i] = '1'
			a[i + p] = '0'
		else:
			if s[i] == '.':
				a[i] = chr(49 - ord(s[i + p]) + 48)
			if s[i + p] == '.':
				a[i + p] = chr(49 - ord(s[i]) + 48)
		for i in range(n):
			if a[i] == '.':
				a[i] = '0'
		print(''.join(a))
		exit()
print('No')


(n, p) = map(int, input().split())
s = list(str(input()))
isPossible = False
for i in range(0, n - p):
	if s[i] == '.':
		if s[i + p] == '1':
			s[i] = '0'
		elif s[i + p] == '0':
			s[i] = '1'
		else:
			s[i] = '1'
			s[i + p] = '0'
		isPossible = True
		break
	elif s[i + p] == '.':
		if s[i] == '1':
			s[i + p] = '0'
		elif s[i] == '0':
			s[i + p] = '1'
		else:
			print('Whoops! Error #1 occured!')
		isPossible = True
		break
	elif s[i] != s[i + p]:
		isPossible = True
		break
if isPossible:
	for j in range(0, n):
		if s[j] == '.':
			s[j] = '0'
	print(''.join(s))
else:
	print('No')


(n, p) = map(int, input().split())
s = input()
t = s.replace('.', '0')
if all((t[i] == t[i + p] for i in range(n - p))):
	k = -1
	for r in range(p - 1, -1, -1):
		x = s[r::p].rfind('.')
		if x != -1 and s[r::p] != '.':
			k = max(k, x * p + r)
	if k == -1:
		print('No')
	else:
		print(t[:k] + '1' + t[k + 1:])
else:
	print(t)


def func(st, sr, n):
	for i in range(len(sr)):
		if (st[i] == '0' or st[i + n] == '0') and (st[i] == '.' or st[i + n] == '.'):
			print(st.replace('.', '1'))
			return 0
		elif (st[i] == '1' or st[i + n] == '1') and (st[i] == '.' or st[i + n] == '.'):
			print(st.replace('.', '0'))
			return 0
		elif st[i] == st[i + n] == '.':
			print(st[:i + 1].replace('.', '0') + st[i + 1:].replace('.', '1'))
			return 0
		elif (st[i] == '0' or st[i + n] == '0') and (st[i] == '1' or st[i + n] == '1'):
			print(st.replace('.', '0'))
			return 0
	print('No')
	return 0
nx = input().split()
n = int(nx[0])
p = int(nx[1])
s = input()
st = s[:n - p]
func(s, st, p)


ip = input()
ip = ip.split(' ')
n = int(ip[0])
p = int(ip[1])
s = list(input())
flag = 0
for i in range(n - p):
	if s[i] == '.' and s[i + p] == '.':
		s[i] = '0'
		s[i + p] = '1'
		flag = 1
	elif s[i] != '.' and s[i + p] == '.':
		if s[i] == '1':
			s[i + p] = '0'
			flag = 1
		else:
			s[i + p] = '1'
			flag = 1
	elif s[i] == '.' and s[i + p] != '.':
		if s[i + p] == '1':
			s[i] = '0'
			flag = 1
		else:
			s[i] = '1'
			flag = 1
	elif s[i] != s[i + p]:
		flag = 1
for i in range(n - p, n):
	if s[i] == '.':
		s[i] = '0'
if flag == 1:
	print(''.join(s))
else:
	print('No')


def main():
	(N, P) = map(int, input().split())
	S = list(input())
	ans = 'No'
	for i in range(N - P):
		if S[i] == '.' and S[i + P] == '.':
			(S[i], S[i + P]) = ('0', '1')
			ans = 'Yes'
		elif S[i] != S[i + P]:
			ans = 'Yes'
			if S[i] == '.':
				S[i] = str(int(not int(S[i + P])))
			elif S[i + P] == '.':
				S[i + P] = str(int(not int(S[i])))
	if ans == 'Yes':
		print(''.join(S).replace('.', '0'))
	else:
		print(ans)
main()


def ans(st):
	str = ''
	for i in st:
		if i == '.':
			str = str + '0'
		else:
			str = str + i
	print(str)
	exit(0)
st = input()
a = st.split(' ')
n = int(a[0])
p = int(a[1])
a.clear()
stt = input()
i = 0
j = p
st = list(stt)
while j < len(st):
	if st[i] != st[j]:
		if st[i] == '0':
			st[j] = '1'
		elif st[i] == '1':
			st[j] = '0'
		elif st[j] == '0':
			st[i] = '1'
		elif st[j] == '1':
			st[i] = '0'
		else:
			exit(2)
		ans(st)
	if st[i] == '.' and st[j] == '.':
		st[i] = '0'
		st[j] = '1'
		ans(st)
	j = j + 1
	i = i + 1
print('No')
exit(0)


(n, k) = map(int, input().split())
s = list(input())
bo = False
chk = False
for i in range(len(s) - k):
	if '.' not in s[i] + s[i + k] and s[i] != s[i + k]:
		chk = True
	elif s[i] == '.' and s[i + k] != '.':
		s[i] = str(1 - int(s[i + k]))
		bo = True
		break
	elif s[i] != '.' and s[i + k] == '.':
		s[i + k] = str(1 - int(s[i]))
		bo = True
		break
	elif s[i + k] + s[i] == '..':
		s[i] = '0'
		s[i + k] = '1'
		bo = True
		break
if bo == False and chk == False:
	print('No')
	exit()
for i in range(len(s)):
	if s[i] == '.':
		s[i] = '1'
print(''.join(s))


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

def main():
	(n, p) = read_nums()
	s = list(input())
	for i in range(n - p):
		(one, two) = (s[i], s[i + p])
		if (one, two) == ('.', '.'):
			s[i] = '1'
			s[i + p] = '0'
			print(''.join(s).replace('.', '0'))
			return
		if one != two:
			if (one, two) == ('.', '0'):
				s[i] = '1'
			elif (one, two) == ('.', '1'):
				s[i] = '0'
			elif (one, two) == ('0', '.'):
				s[i + p] = '1'
			elif (one, two) == ('1', '.'):
				s[i + p] = '0'
			print(''.join(s).replace('.', '0'))
			return
	print('No')
main()


(n, p) = (int(x) for x in input().split())
s = list(input())
ans = False
for start in range(p):
	curr = ''.join(s[start::p])
	if '.' in curr:
		if '0' in curr:
			curr = curr.replace('.', '1')
			ans = True
		elif '1' in curr:
			curr = curr.replace('.', '0')
			ans = True
		elif len(curr) > 1:
			curr = '1' + curr[1:]
			curr = curr.replace('.', '0')
			ans = True
		else:
			curr = '1' + curr[1:]
		s[start::p] = list(curr).copy()
	elif '0' in curr and '1' in curr:
		ans = True
if not ans:
	print('No')
else:
	print(*s, sep='')


def read():
	return int(input())

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

def readlist():
	return list(map(int, input().split()))
(N, P) = readmap()
S = list(input())
if N == P:
	print('No')
	quit()
for i in range(N):
	if i >= P and (S[i] != S[i - P] or (S[i] == '.' and S[i - P] == '.')):
		if S[i] == '.' and S[i - P] == '.':
			S[i] = '1'
			S[i - P] = '0'
			for j in range(N):
				if S[j] == '.':
					S[j] = '0'
			print(''.join(S))
			quit()
		elif S[i] == '.':
			if S[i - P] == '0':
				S[i] = '1'
			else:
				S[i] = '0'
			for j in range(N):
				if S[j] == '.':
					S[j] = '0'
			print(''.join(S))
			quit()
		elif S[i - P] == '.':
			if S[i] == '0':
				S[i - P] = '1'
			else:
				S[i - P] = '0'
			for j in range(N):
				if S[j] == '.':
					S[j] = '0'
			print(''.join(S))
			quit()
		else:
			for j in range(N):
				if S[j] == '.':
					S[j] = '0'
			print(''.join(S))
			quit()
print('No')


(n, p) = map(int, input().split())
s = list(input())
bad = True
for i in range(n - p):
	if s[i] == s[i + p] == '.':
		s[i] = 0
		s[i + p] = 1
		bad = False
	elif s[i] == '.':
		s[i] = 1 - int(s[i + p])
		bad = False
	elif s[i + p] == '.':
		s[i + p] = 1 - int(s[i])
		bad = False
	elif s[i] != s[i + p]:
		bad = False
while '.' in s:
	s[s.index('.')] = 0
if bad:
	print('No')
	exit()
print(''.join(map(str, s)))


(n, p) = map(int, input().split())
s = input()
for i in range(p, n):
	(x, y) = (s[i % p], s[i])
	if x == y != '.':
		continue
	if x == y == '.':
		s = (s[:i] + '0' + s[i + 1:]).replace('.', '1')
	elif '1' in [x, y]:
		s = s.replace('.', '0')
	else:
		s = s.replace('.', '1')
	print(s)
	exit()
print('NO')


from sys import stdin, stdout
import math
from collections import Counter
(n, p) = stdin.readline().strip().split(' ')
(n, p) = (int(n), int(p))
s = stdin.readline().strip()
arr = [[] for i in range(p)]
for i in range(n):
	arr[i % p].append(s[i])
dctr = [None for i in range(p)]
for i in range(p):
	dctr[i] = Counter(arr[i])
have_option = [True for i in range(p)]
for i in range(p):
	if len(dctr[i]) == 1 and (('1' in dctr[i] or '0' in dctr[i]) or ('.' in dctr[i] and dctr[i]['.'] == 1)):
		have_option[i] = False
if True in have_option:
	for i in range(p):
		if have_option[i] == False:
			for x in range(len(arr[i])):
				if arr[i][x] == '.':
					arr[i][x] = '0'
		elif '1' in dctr[i]:
			for x in range(len(arr[i])):
				if arr[i][x] == '.':
					arr[i][x] = '0'
		elif '0' in dctr[i]:
			for x in range(len(arr[i])):
				if arr[i][x] == '.':
					arr[i][x] = '1'
		else:
			for x in range(len(arr[i])):
				if arr[i][x] == '.':
					arr[i][x] = '0'
			arr[i][0] = '1'
	ans = ''
	maxlen = max([len(arr[i]) for i in range(p)])
	for i in range(maxlen):
		for j in range(p):
			if len(arr[j]) > i:
				ans += arr[j][i]
	stdout.write(ans + '\n')
else:
	stdout.write('No\n')


from functools import cmp_to_key
import sys

def getIntList():
	return list(map(int, input().split()))
(n, p) = getIntList()
s = input()
z = list(s)
n = len(s)
flag = False
for i in range(n):
	if i + p < n:
		if s[i] == '.':
			if s[i + p] == '0':
				z[i] = '1'
			elif s[i + p] == '1':
				z[i] = '0'
			else:
				z[i] = '0'
				z[i + p] = '1'
			flag = True
			break
		elif s[i + p] == '.':
			if s[i] == '0':
				z[i + p] = '1'
			else:
				z[i + p] = '0'
			flag = True
			break
		elif s[i] != s[i + p]:
			flag = True
			break
if not flag:
	print('NO')
	sys.exit()
for i in range(n):
	if z[i] == '.':
		z[i] = '0'
print(''.join(z))


(n, m) = map(int, input().split())
s = input()
l = list(s)
i = 0
flag = 0
flag2 = 0
while i < n - m:
	if l[i] != l[i + m]:
		flag = 1
		if l[i] != '.' and l[i + m] != '.':
			break
		else:
			if l[i + m] == '.':
				if l[i] == '0':
					l[i + m] = '1'
				else:
					l[i + m] = '0'
			elif l[i + m] == '0':
				l[i] = '1'
			else:
				l[i] = '0'
			break
	elif l[i] == l[i + m] and l[i] == '.':
		l[i] = '0'
		l[i + m] = '1'
		flag = 1
		break
	i += 1
if flag == 0:
	print('No')
else:
	for i in range(len(l)):
		if l[i] == '.':
			l[i] = '0'
	print(''.join(l))


(n, p) = map(int, input().split())
s = input()
flag = -1
for i in range(p, n, p):
	if i + p < n:
		s1 = s[i - p:i]
		s2 = s[i:i + p]
	else:
		s1 = s[i - p:n - p]
		s2 = s[i:n]
	if '.' in s1:
		index = s1.find('.')
		if s2[index] != '.':
			flag = 1
		else:
			flag = 2
		index += i - p
		break
	elif '.' in s2:
		index = s2.find('.')
		index += i
		flag = 3
		break
	elif s1 != s2:
		flag = 0
		break
if flag == -1:
	print('No')
elif flag == 0:
	print(s.replace('.', '0'))
elif flag == 1:
	s = s[:index] + str(1 - int(s[index + p])) + s[index + 1:]
	print(s.replace('.', '0'))
elif flag == 2:
	s = s[:index] + '1' + s[index + 1:index + p] + '0' + s[index + p + 1:]
	print(s.replace('.', '0'))
elif flag == 3:
	s = s[:index] + str(1 - int(s[index - p])) + s[index + 1:]
	print(s.replace('.', '0'))


def main():
	(n, p) = input().split(' ')
	s = input()
	n = int(n)
	p = int(p)
	aux = 0
	aux2 = 0
	menor = []
	maior = []
	for i in range(n - p):
		menor.append(i + 1)
		maior.append(i + 1 + p)
	for i in range(len(menor)):
		if s[menor[i] - 1] == '.' and s[maior[i] - 1] != '.':
			if s[maior[i] - 1] == '0':
				print(s.replace('.', '1'))
			else:
				print(s.replace('.', '0'))
			aux = 1
			break
		elif s[menor[i] - 1] != '.' and s[maior[i] - 1] == '.':
			if s[menor[i] - 1] == '0':
				print(s.replace('.', '1'))
			else:
				print(s.replace('.', '0'))
			aux = 1
			break
		elif s[menor[i] - 1] == '.' and s[maior[i] - 1] == '.':
			novo = list(s)
			novo[menor[i] - 1] = '0'
			s = ''.join(novo)
			print(s.replace('.', '1'))
			aux = 1
			break
		elif s[menor[i] - 1] != s[maior[i] - 1]:
			print(s.replace('.', '0'))
			aux = 1
			break
	if aux == 0:
		print('No')
main()


a = [int(q) for q in input().strip().split()]
b = list(input())
t = 0
for k in range(a[0] - a[1]):
	if b[k] == b[k + a[1]] and (b[k] == '1' or b[k] == '0'):
		t += 1
	elif b[k] == b[k + a[1]] and b[k] == '.':
		b[k] = '0'
		b[k + a[1]] = '1'
	elif b[k] == '.':
		if b[k + a[1]] == '1':
			b[k] = '0'
		else:
			b[k] = '1'
	elif b[k + a[1]] == '.':
		if b[k] == '1':
			b[k + a[1]] = '0'
		else:
			b[k + a[1]] = '1'
if t == a[0] - a[1]:
	print('No')
else:
	for k in range(len(b)):
		if b[k] == '.':
			b[k] = '1'
	print(''.join(b))


def prog():
	a = [int(i) for i in input().split()]
	n = a[0]
	g = a[1]
	b = input()
	s = ''
	for (i, _) in enumerate(b):
		if i + g < n and (b[i + g] != b[i] or (b[i + g] == '.' and b[i] == '.')):
			if b[i] == '.':
				if b[i + g] == '.':
					s += b[:i]
					s += '0'
					s += b[i + 1:i + g]
					s += '1'
					s += b[i + g + 1:]
				elif b[i + g] == '1':
					s += b[:i]
					s += '0'
					s += b[i + 1:]
				elif b[i + g] == '0':
					s += b[:i]
					s += '1'
					s += b[i + 1:]
			elif b[i + g] == '.':
				s += b[:i + g]
				if b[i] == '1':
					s += '0'
				else:
					s += '1'
				s += b[i + g + 1:]
			else:
				s += b
			s = s.replace('.', '0')
			print(s)
			return
	print('NO')
	return
	return
prog()


(n, p) = map(int, input().split())
a = input()
s = []
for i in range(len(a)):
	s.append(a[i])

def fill(s, index, elem):
	for i in range(len(s)):
		if s[i] == '.':
			if i == index:
				s[i] = elem
			else:
				s[i] = '0'
	return s

def solve(s):
	for i in range(n - p):
		if s[i] == '1':
			if s[i + p] == '0' or s[i + p] == '.':
				return fill(s, i + p, '0')
		if s[i] == '0':
			if s[i + p] == '1' or s[i + p] == '.':
				return fill(s, i + p, '1')
		if s[i] == '.':
			if s[i + p] == '.':
				s[i] = '0'
				return fill(s, i + p, '1')
			if s[i + p] == '1':
				return fill(s, i, '0')
			if s[i + p] == '0':
				return fill(s, i, '1')
	return 'No'
ans = solve(s)
for i in ans:
	print(i, sep='', end='')


(n, p) = list(map(int, input().split()))
s = str(input())
ss = list(s)
has = False
for i in range(0, len(s) - p):
	left = s[i]
	right = s[i + p]
	if left == right and left != '.':
		continue
	if left == right:
		ss[i] = '0'
		ss[i + p] = '1'
		has = True
		break
	elif left == '.':
		ss[i] = '0' if right == '1' else '1'
		has = True
		break
	elif right == '.':
		ss[i + p] = '0' if left == '1' else '1'
		has = True
		break
	else:
		has = True
		break
if has:
	print(''.join(ss).replace('.', '0'))
else:
	print('No')


t = input().split(' ')
a = list(input())
c = []
d = a[:]
for i in range(int(t[0]) - int(t[1])):
	if a[i] != '.' and a[i + int(t[1])] != '.' and (a[i] == a[i + int(t[1])]):
		c.append('NO')
	if a[i] == '0' and a[i + int(t[1])] == '.':
		d[i + int(t[1])] = '1'
	if a[i] == '1' and a[i + int(t[1])] == '.':
		d[i + int(t[1])] = '0'
	if a[i] == '.' and a[i + int(t[1])] == '0':
		d[i] = '1'
	if a[i] == '.' and a[i + int(t[1])] == '1':
		d[i] = '0'
	if a[i] == '.' and a[i + int(t[1])] == '.':
		d[i] = '0'
		d[i + int(t[1])] = '1'
for i in range(len(a)):
	if d[i] == '.':
		d[i] = '0'
if len(c) == int(t[0]) - int(t[1]):
	print('NO')
else:
	print(''.join(d))


(n, p) = map(int, input().strip().split())
s = input().strip()
found = False
for i in range(len(s) - p):
	(a, b) = (s[i], s[i + p])
	if not (a == '1' and b == '1' or (a == '0' and b == '0')):
		found = True
		if a != '.':
			b = '1' if a == '0' else '0'
		elif b != '.':
			a = '1' if b == '0' else '0'
		else:
			(a, b) = ('1', '0')
		print(s[:i].replace('.', '0') + a + s[i + 1:i + p].replace('.', '0') + b + s[i + p + 1:].replace('.', '0'))
		break
if not found:
	print('NO')


(n, p) = map(int, input().split())
s = input()
x = []
for j in s:
	x.append(j)
ind = False
for i in range(n):
	if i + p < n:
		if not ind and x[i + p] == '.':
			if x[i] != '.':
				x[i + p] = 1 - int(x[i])
			else:
				x[i] = 0
				x[i + p] = 1
			ind = True
		elif not ind and x[i] == '.':
			x[i] = 1 - int(x[i + p])
			ind = True
		elif not ind and x[i] != x[i + p]:
			ind = True
		elif ind:
			if x[i] == '.':
				x[i] = 0
	elif x[i] == '.':
		x[i] = 0
if ind:
	for j in range(n):
		print(x[j], end='')
else:
	print('No')


inp = input().split()
(N, P) = (int(inp[0]), int(inp[1]))
S_prim = input()
S = []
for l in S_prim:
	S.append(l)
period_free = False
for p in range(0, P):
	liz = []
	p_safe = p
	while p < N:
		liz.append(S[p])
		p += P
	if len(liz) > 1 and ('.' in liz or ('1' in liz and '0' in liz)):
		period_free = True
if not period_free:
	print('No')
else:
	reversal = ['1', '0']
	for i in range(0, N):
		if S[i] == '.':
			if i - P >= 0:
				if S[i - P] != '.':
					S[i] = reversal[int(S[i - P])]
			if i + P < N:
				if S[i + P] != '.':
					S[i] = reversal[int(S[i + P])]
			if S[i] == '.':
				S[i] = '0'
	for l in S:
		print(l, end='')
	print()


(n, p) = map(int, input().split())
s = input().strip()
arr = []
for i in range(p):
	arr.append([])
for i in range(n):
	arr[i % p].append(s[i])
flag = 0
for i in range(p):
	if arr[i].count('.') == 1 and len(arr[i]) >= 2:
		if min(arr[i].count('0'), arr[i].count('1')) == arr[i].count('0'):
			arr[i][arr[i].index('.')] = '0'
		else:
			arr[i][arr[i].index('.')] = '1'
		flag = 1
		break
	if arr[i].count('.') >= 2:
		if min(arr[i].count('0'), arr[i].count('1')) == arr[i].count('0'):
			arr[i][arr[i].index('.')] = '0'
		else:
			arr[i][arr[i].index('.')] = '1'
		flag = 1
		break
	if arr[i].count('0') > 0 and arr[i].count('0') < len(arr[i]) or (arr[i].count('1') > 0 and arr[i].count('1') < len(arr[i])):
		flag = 1
		break
if flag == 1:
	ans = []
	for j in range(n // p + 1):
		for i in range(len(arr)):
			if j < len(arr[i]):
				if arr[i][j] == '.':
					ans.append('1')
				else:
					ans.append(arr[i][j])
	print(''.join(ans))
else:
	print('No')


nums = input()
n = int(nums.split(' ')[0])
p = int(nums.split(' ')[1])
tar = input()
tar = list(tar)
fill_zero = False
for i in range(len(tar)):
	if i + p >= n:
		break
	elif tar[i] != '.' and tar[i + p] != '.':
		if tar[i] != tar[i + p]:
			fill_zero = True
	else:
		if tar[i] == '.' and tar[i + p] == '.':
			tar[i] = '0'
			tar[i + p] = '1'
		elif tar[i] == '.' and tar[i + p] != '.':
			tar[i] = str(1 - int(tar[i + p]))
		elif tar[i] != '.' and tar[i + p] == '.':
			tar[i + p] = str(1 - int(tar[i]))
		fill_zero = True
if fill_zero == True:
	for i in range(len(tar)):
		if tar[i] == '.':
			tar[i] = '0'
	print(''.join(tar))
else:
	print('No')


[n, p] = map(int, input().strip().split())
s = input().strip()

def ceil(a, b):
	return -(-a // b)
sq = [[s[p * j + i] for j in range(ceil(n - i, p))] for i in range(p)]
poss = False
for row in sq:
	d0 = row.count('0')
	d1 = row.count('1')
	dp = row.count('.')
	if d0 * d1 > 0:
		poss = True
		break
	if dp > 0:
		pp = row.index('.')
		if d0 > 0:
			row[pp] = '1'
			poss = True
			break
		elif d1 > 0:
			row[pp] = '0'
			poss = True
			break
		elif dp > 1:
			ppp = row.index('.', pp + 1)
			row[pp] = '0'
			row[ppp] = '1'
			poss = True
			break
if poss:
	for row in sq:
		for i in range(len(row)):
			if row[i] == '.':
				row[i] = '0'
	ss = [sq[i][j] for j in range(n // p) for i in range(p)]
	for i in range(n % p):
		ss.append(sq[i][-1])
	print(''.join(ss))
else:
	print('No')


def STR():
	return list(input())

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

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

def MAP2():
	return map(float, input().split())

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

def STRING():
	return input()
import string
import sys
from heapq import heappop, heappush
from bisect import *
from collections import deque, Counter, defaultdict
from math import *
from itertools import permutations, accumulate
dx = [-1, 1, 0, 0]
dy = [0, 0, 1, -1]

def solve(s, k, n):
	st = set()
	for i in range(n):
		j = i + k
		if j <= n - 1:
			if s[i] == s[j]:
				st.add(0)
			else:
				st.add(1)
	return st
(n, k) = MAP()
s = STR()
for i in range(n):
	x = i
	y = i + k
	if y <= n - 1:
		if s[x] == '.' and s[y] == '.':
			s[x] = '1'
			s[y] = '0'
		if s[x] == '.' and s[y] != '.':
			s[x] = str(1 - int(s[y]))
		if s[y] == '.' and s[x] != '.':
			s[y] = str(1 - int(s[x]))
	elif s[x] == '.':
		s[x] = '1'
r = solve(s, k, n)
if len(r) == 2 or (len(r) == 1 and 1 in r):
	print(''.join(s))
else:
	print('No')


(n, m) = map(int, input().split())
st = input()
lr = n - m
for i in range(lr):
	if i + m < n and st[i] != st[i + m] or (i + m < n and st[i] == '.' and (st[i + m] == '.')):
		if st[i] == '.' and st[i + m] == '.':
			for j in range(n):
				if j == i:
					print(0, end='')
				elif j == i + m:
					print(1, end='')
				elif st[j] == '.':
					print(0, end='')
				else:
					print(st[j], end='')
		elif st[i] != '.' and st[i + m] != '.':
			for j in range(n):
				if st[j] == '.':
					print(0, end='')
				else:
					print(st[j], end='')
		else:
			st = list(st)
			if st[i] != '.' and st[i] == '1':
				st[i + m] = '0'
			elif st[i] != '.' and st[i] == '0':
				st[i + m] = '1'
			elif st[i + m] == '0':
				st[i] = '1'
			else:
				st[i] = '0'
			for j in range(n):
				if st[j] == '.':
					print(0, end='')
				else:
					print(st[j], end='')
		print()
		exit()
print('NO')


(p, n) = map(int, input().split())
s = input()
flag = 0
pos = 0
for j in range(p - n):
	a = s[j]
	if s[j] != s[j + n] or s[j] == '.':
		flag = 1
		pos = j
	if flag == 1:
		t = ''
		for i in range(p):
			if s[i] == '.':
				if i == pos:
					if a == '1' or (a == '.' and s[j + n] == '1'):
						t = t + '0'
					elif a == '0' or (a == '.' and s[j + n] == '0'):
						t = t + '1'
					else:
						t = t + '1'
				elif i == pos + n:
					if t[pos] == '0':
						t = t + '1'
					else:
						t = t + '0'
				else:
					t = t + '0'
			else:
				t = t + s[i]
		print(t)
		break
if flag == 0:
	print('No')


(n, p) = map(int, input().split())
s = list(input())
flag = False
for i in range(n):
	if s[i] == '.':
		s[i] = '0'
		if i - p >= 0 and s[i - p] == '0' or (i + p < n and s[i + p] == '0'):
			s[i] = '1'
	if i + p < n and s[i + p] != s[i]:
		flag = True
print(''.join(s)) if flag else print('No')


(n, p) = input().split()
n = int(n)
p = int(p)
s = input()
snew = ''
for i in range(p):
	k = i + p
	sym = s[i]
	if sym != '.':
		OK = True
		while k < n:
			if s[k] != sym:
				OK = False
				break
			k += p
	else:
		OK = False
	if OK == False and k < n:
		if sym == '1':
			snew = s[:k] + '0' + s[k + 1:]
		elif sym == '0':
			snew = s[:k] + '1' + s[k + 1:]
		elif sym == '.':
			if s[k] == '0':
				snew = s[:i] + '1' + s[i + 1:]
			elif s[k] == '1':
				snew = s[:i] + '0' + s[i + 1:]
			elif s[k] == '.':
				snew = s[:i] + '0' + s[i + 1:k] + '1' + s[k + 1:]
		break
if snew != '':
	rez = ''
	for i in range(len(snew)):
		if snew[i] != '.':
			rez += snew[i]
		else:
			rez += '0'
	print(rez)
else:
	print('No')


(a, b) = map(int, input().split())
x = list(str(input()))
s = ['0'] + x
bo = 0
for i in range(1, a + 1):
	j = i + b
	if j > a:
		break
	if s[i] == '0' and s[j] != '0':
		bo = 1
		if s[j] == '.':
			s[j] = '1'
			break
	if s[i] == '1' and s[j] != '1':
		bo = 2
		if s[j] == '.':
			s[j] = '0'
			break
	if s[i] == '.' and s[j] == '.':
		bo = 44
		s[j] = '1'
		break
	if s[i] == '.' and s[j] != '.':
		bo = 3
		if s[j] == '1':
			s[i] = '0'
			break
		if s[j] == '0':
			s[i] = '1'
		break
for i in range(a + 1):
	if s[i] == '.':
		s[i] = '0'
if bo == 0:
	print('NO')
	exit()
else:
	for i in range(1, a + 1):
		print(s[i], end='')


(n, p) = map(int, input().split())
s = input()
t = s.replace('.', '0')
if any((t[i] != t[i + p] for i in range(n - p))):
	print(t)
	exit()
else:
	x = s.find('.')
	if x + p < n:
		print(t[:x] + '1' + t[x + 1:])
		exit()
	x = s.rfind('.')
	if x - p >= 0:
		print(t[:x] + '1' + t[x + 1:])
		exit()
print('No')


from collections import Counter
import string
import math
import sys

def array_int():
	return [int(i) for i in sys.stdin.readline().split()]

def vary(arrber_of_variables):
	if arrber_of_variables == 1:
		return int(sys.stdin.readline())
	if arrber_of_variables >= 2:
		return map(int, sys.stdin.readline().split())

def makedict(var):
	return dict(Counter(var))
mod = 1000000007
(n, p) = vary(2)
s = list(input())
flag = 0
for i in range(n):
	if i + p < n:
		if s[i] == '.' and s[i + p] == '.':
			s[i] = '1'
			s[i + p] = '0'
			flag = 1
			break
		if s[i] == '.':
			s[i] = str(1 ^ int(s[i + p]))
			flag = 1
			break
		if s[i + p] == '.':
			s[i + p] = str(1 ^ int(s[i]))
			flag = 1
			break
		if s[i] != s[i + p]:
			flag = 1
			break
if flag == 0:
	print('No')
else:
	ans = ''
	for i in range(n):
		if s[i] == '.':
			ans += '1'
		else:
			ans += s[i]
	print(ans)


def rev(k):
	return '0' if k == '1' else '1'
(n, p) = map(int, input().split())
a = input()
b = list(a)
f = False
for i in range(n - p):
	c = a[i]
	d = a[i + p]
	if '.' in [c, d]:
		if c == '.' and d != '.':
			b[i] = rev(d)
		elif c != '.' and d == '.':
			b[i + p] = rev(c)
		else:
			b[i] = '1'
			b[i + p] = '0'
		f = True
	elif d != c:
		f = True
if f:
	for i in b:
		print(i if i != '.' else '0', end='')
	print()
else:
	print('No')


(n, p) = map(int, input().split())
s = input()
f = 1
for i in range(len(s) - p):
	if s[i] != '.' and s[i + p] != '.' and (s[i] == s[i + p]):
		continue
	else:
		f = 0
		break
if f == 1:
	print('No')
else:
	x = []
	for i in s:
		x.append(i)
	for i in range(len(s) - p):
		if x[i] == '.' and x[i + p] == '.':
			x[i] = '1'
			x[i + p] = '0'
		if x[i] == '.' and x[i + p] == '0':
			x[i] = '1'
		if x[i] == '.' and x[i + p] == '1':
			x[i] = '0'
		if x[i] == '1' and x[i + p] == '.':
			x[i + p] = '0'
		if x[i] == '0' and x[i + p] == '.':
			x[i + p] = '1'
	for i in range(len(s)):
		if x[i] == '.':
			x[i] = '0'
	print(''.join(x))


(n, p) = map(int, input().split())
s = list(input())
made_no_p = 0
for i in range(n - p + 1):
	if s[i] == '.':
		if i + p < n:
			if s[i + p] == '.':
				s[i] = '1'
				s[i + p] = '0'
				made_no_p = 1
			elif s[i + p] == '0':
				s[i] = '1'
				made_no_p = 1
			elif s[i + p] == '1':
				s[i] = '0'
				made_no_p = 1
	if i + p < n:
		if s[i + p] == '.':
			if s[i] == '0':
				s[i + p] = '1'
				made_no_p = 1
			if s[i] == '1':
				s[i + p] = '0'
				made_no_p = 1
		if s[i] != s[i + p]:
			made_no_p = 1
if made_no_p:
	for i in range(n):
		if s[i] == '.':
			s[i] = '1'
	print(''.join(s))
else:
	print('No')


def solve(n, p, s):
	for i in range(n):
		if i + p < n:
			if s[i] != '.' and s[i + p] != '.' and (s[i] != s[i + p]):
				return ''.join(s).replace('.', '0')
			if s[i] == '.' and s[i + p] == '1':
				s[i] = '0'
				return ''.join(s).replace('.', '0')
			if s[i] == '.' and s[i + p] == '0':
				s[i] = '1'
				return ''.join(s).replace('.', '0')
			if s[i] == '.' and s[i + p] == '.':
				s[i] = '1'
				return ''.join(s).replace('.', '0')
			if s[i] == '1' and s[i + p] == '.':
				s[i + p] = '0'
				return ''.join(s).replace('.', '0')
			if s[i] == '0' and s[i + p] == '.':
				s[i + p] = '1'
				return ''.join(s).replace('.', '0')
	return 'No'
(n, p) = [int(x) for x in input().split()]
s = input()
print(solve(n, p, list(s)))


import sys
(n, p) = map(int, input().split())
s = input()
for i in range(len(s)):
	if i + p < n:
		if s[i] != s[i + p] or s[i] == '.':
			r = s.replace('.', '0')
			r = list(r)
			if s[i] == '.' and s[i + p] == '.':
				r[i] = '1'
				r[i + p] = '0'
			elif s[i] == '.':
				r[i] = str(int(not int(s[i + p])))
			elif s[i + p] == '.':
				r[i + p] = str(int(not int(s[i])))
			print(''.join(r))
			sys.exit()
print('No')


(n, p) = map(int, input().split())
s = list(input())
cnt = 0
oe = 0
for i in range(n):
	if i + p < n and (s[i] == s[i + p] == '1' or s[i] == s[i + p] == '0'):
		cnt += 1
		if cnt == n - p:
			break
	if s[i] == '.':
		if i + p < n and s[i + p] == '0':
			s[i] = '1'
		elif i + p < n and s[i + p] == '1':
			s[i] = '0'
		else:
			s[i] = '1'
	if i + p < n and s[i + p] == '.':
		if s[i] == '1':
			s[i + p] = '0'
		elif s[i] == '0':
			s[i + p] = '1'
		else:
			s[i] = '1'
			s[i + p] = '0'
if cnt == n - p:
	print('NO')
else:
	ans = ''.join(s)
	print(ans)


(n, p) = input().strip().split()
(n, p) = (int(n), int(p))
s = input()
flag = True
j = 0
for i in range(len(s) - p):
	if s[i] != s[i + p] or s[i] == '.':
		flag = False
		j = i
		break
if flag:
	print('No\n')
else:
	if s[j] == '.' and s[j + p] != '.':
		s = s[:j] + str(int(not bool(int(s[j + p])))) + s[j + 1:]
	elif s[j] != '.' and s[j + p] == '.':
		s = s[:j + p] + str(int(not bool(int(s[j])))) + s[j + p + 1:]
	elif s[j + p] == '.' and s[j] == '.':
		s = s[:j] + '0' + s[j + 1:]
		s = s[:j + p] + '1' + s[j + p + 1:]
	s = s.replace('.', '0')
	print(s)


(n, p) = map(int, input().split())
s = input()
l = list(s)
su = 0
for i in range(n - p):
	if l[i] == '.' and l[i + p] == '.':
		l[i] = '1'
		l[i + p] = '0'
		su += 1
		break
	elif l[i] == '.' and (l[i + p] == '0' or l[i + p] == '1'):
		if l[i + p] == '0':
			l[i] = '1'
			su += 1
			break
		else:
			l[i] = '0'
			su += 1
			break
	elif l[i + p] == '.' and (l[i] == '0' or l[i] == '1'):
		if l[i] == '0':
			l[i + p] = '1'
			su += 1
			break
		else:
			l[i + p] = '0'
			su += 1
			break
	elif l[i] != l[i + p] and l[i] != '.' and (l[i + p] != '.'):
		su += 1
		break
y = ''.join(l)
if su != 1:
	print('No')
else:
	print(y.replace('.', '0'))


(n, p) = map(int, input().split())
s = input()
sl = [i for i in s]
le = len(s)
f = 0
for i in range(le - p):
	if s[i] == '0' and (s[i + p] == '1' or s[i + p] == '.'):
		if sl[i + p] == '.':
			sl[i + p] = '1'
		f = 1
		break
	elif s[i] == '1' and (s[i + p] == '0' or s[i + p] == '.'):
		if sl[i + p] == '.':
			sl[i + p] = '0'
		f = 1
		break
	elif s[i] == '.':
		if sl[i + p] == '1':
			sl[i] = '0'
		elif sl[i + p] == '0':
			sl[i] = '1'
		else:
			sl[i] = '0'
			sl[i + p] = '1'
		f = 1
		break
if f:
	for i in sl:
		if i == '.':
			print('0', end='')
		else:
			print(i, end='')
else:
	print('no')


(n, p) = [int(x) for x in input().split()]
s = list(input())
found = False
for idx in range(n - p):
	if s[idx] == '.' and s[p + idx] == '1':
		s[idx] = '0'
		found = True
		break
	elif s[idx] == '.' and s[p + idx] == '0':
		s[idx] = '1'
		found = True
		break
	elif s[idx] == '.' and s[p + idx] == '.':
		s[idx] = '1'
		s[idx + p] = '0'
		found = True
		break
	elif s[idx] == '0' and s[p + idx] == '.':
		s[idx + p] = '1'
		found = True
		break
	elif s[idx] == '1' and s[p + idx] == '.':
		s[idx + p] = '0'
		found = True
		break
	elif s[idx] != s[idx + p]:
		found = True
		break
if found:
	for idx in range(n):
		if s[idx] == '.':
			s[idx] = '0'
	print(''.join(s))
else:
	print('No')


(a, p) = map(int, input().split())
s = list(input())
n = len(s)
d = []
stop = 0
for i in range(p):
	d = []
	count = 0
	for j in range(i, n, p):
		d.append(s[j])
		if count == 0:
			count = s[j]
			count_index = j
		elif count != s[j]:
			stop = 1
			if count == '.' and s[j] == '1':
				s[count_index] = '0'
			elif count == '.' and s[j] == '0':
				s[count_index] = '1'
			elif count == '1' and s[j] == '.':
				s[j] = '0'
			elif count == '0' and s[j] == '.':
				s[j] = '1'
		elif count == s[j] and count == '.':
			s[count_index] = '0'
			s[j] = '1'
			stop = 1
	if stop == 1:
		for i in s:
			if i == '.':
				print(0, end='')
			else:
				print(i, end='')
		break
if stop == 0:
	print('No')


(n, p) = map(int, input().split())
a = input()
b = list(a)
for i in range(p):
	j = i
	c = a[j]
	if j + p < n and a[j] == '.':
		c = a[j + p]
	if c == '.':
		c = '0'
	cnt = 0
	for j in range(i, n, p):
		if a[j] == '.':
			if cnt % 2 == 0:
				if c == '0':
					b[j] = '1'
				else:
					b[j] = '0'
			else:
				b[j] = c
			cnt += 1
ok = 0
for i in range(p, n):
	if b[i] != b[i - p]:
		ok = 1
if ok == 1:
	print(''.join(b))
else:
	print('No')


(b, c) = map(int, input().split())
a = input()
d = []
e = 0
f = 0
for i in range(b - c):
	if a[i] == '0' and a[i + c] == '1' or (a[i] == '1' and a[i + c] == '0'):
		e = 1
		f = -5
		break
	elif a[i] == '.' and a[i + c] == '.':
		f = i
		e = 2
		break
	elif a[i] == '.':
		f = i
		e = 1
		break
	elif a[i + c] == '.':
		f = i + c
		e = 10
		break
	else:
		e = 0
if e == 0:
	print('NO')
else:
	if f == -5:
		for i in a:
			if i != '.':
				d.append(i)
			if i == '.':
				d.append('0')
	elif e == 2:
		for i in range(len(a)):
			if i == f:
				d.append('1')
			elif i == f + c:
				d.append('0')
			elif a[i] == '.':
				d.append('0')
			else:
				d.append(a[i])
	elif e == 10:
		for i in range(len(a)):
			if i == f and f - c > -1 and (a[f - c] == '0'):
				d.append('1')
			elif a[i] == '.':
				d.append('0')
			else:
				d.append(a[i])
	else:
		for i in range(len(a)):
			if i == f and f + c <= b and (a[f + c] == '0'):
				d.append('1')
			elif a[i] == '.':
				d.append('0')
			else:
				d.append(a[i])
	print(*d, sep='')


(n, p) = map(int, input().strip().split(' '))
s = list(input())
for i in range(n - p):
	if s[i] == '1':
		if s[i + p] == '.':
			s[i + p] = '0'
	elif s[i] == '0':
		if s[i + p] == '.':
			s[i + p] = '1'
	elif s[i + p] == '1':
		s[i] = '0'
	elif s[i + p] == '0':
		s[i] = '1'
	else:
		s[i] = '1'
		s[i + p] = '0'
for i in range(n):
	if s[i] == '.':
		s[i] = '1'
ans = 0
for i in range(n - p):
	if s[i] != s[i + p]:
		ans = 1
		break
if ans == 1:
	t = ''
	for i in s:
		t += i
	print(t)
else:
	print('NO')


(n, p) = map(int, input().split())
s = list(input())
f = True
for i in range(n - p):
	if s[i] == '.' and s[i + p] == '.':
		s[i] = '1'
		s[i + p] = '0'
		f = False
		break
	elif s[i] == '.':
		s[i] = str(1 - int(s[i + p]))
		f = False
		break
	elif s[i + p] == '.':
		s[i + p] = str(1 - int(s[i]))
		f = False
		break
	elif s[i] != s[i + p]:
		f = False
		break
if f:
	print('NO')
else:
	for p in s:
		if p == '.':
			print(1, end='')
		else:
			print(p, end='')
	print()


(a, b) = map(int, input().split())
z = '$' + input()
z = z.replace('', ' ').split()
for i in range(1, a - b + 1):
	if z[i] == z[i + b] == '.':
		z[i] = '1'
		z[i + b] = '0'
		exit(print(''.join(z[1:]).replace('.', '0')))
	elif z[i] in '01' and z[i + b] in '01' and (z[i] != z[i + b]):
		exit(print(''.join(z[1:]).replace('.', '1')))
	elif z[i] == '.' and z[i + b] == '0' or (z[i] == '0' and z[i + b] == '.'):
		exit(print(''.join(z[1:]).replace('.', '1')))
	elif z[i] == '.' and z[i + b] == '1' or (z[i] == '1' and z[i + b] == '.'):
		exit(print(''.join(z[1:]).replace('.', '0')))
print('No')


(n, p) = map(int, input().split())
s = list(input())
ans = False
for i in range(n - p):
	if s[i] != s[i + p] or s[i] == '.':
		ans = True
if ans == False:
	print('No')
	exit()
for i in range(n - p):
	if s[i] == '.' or s[i + p] == '.':
		if s[i] == s[i + p]:
			s[i] = '1'
			s[i + p] = '0'
		if s[i] == '.':
			if s[i + p] == '1':
				s[i] = '0'
			else:
				s[i] = '1'
		elif s[i] == '1':
			s[i + p] = '0'
		else:
			s[i + p] = '1'
for i in range(n):
	if s[i] == '.':
		s[i] = '1'
print(''.join(s))


(n, p) = map(int, input().split())
a = input()
a = list(a)
flag = 0
flag1 = 0
for i in range(n):
	if i <= n - p - 1:
		if a[i] == a[i + p] and a[i] != '.':
			flag = 1
			continue
		elif a[i] == '1' and a[i + p] == '.':
			a[i + p] = '0'
		elif a[i] == '.' and a[i + p] == '1':
			a[i] = '0'
		elif a[i] == '0' and a[i + p] == '.':
			a[i + p] = '1'
		elif a[i] == '.' and a[i + p] == '0':
			a[i] = '1'
		elif a[i] == a[i + p] == '.':
			a[i] = '0'
			a[i + p] = '1'
		flag1 = 1
	elif a[i] == '.':
		a[i] = '0'
if flag1 == 0:
	print('No')
else:
	a = ''.join(a)
	print(a)


from sys import exit
(n, p) = map(int, input().split())
s = list(input())
ans = s[:]
for i in range(n):
	if i < n - p:
		if ans[i] == '.':
			if ans[i + p] == '.':
				(ans[i], ans[i + p]) = ('0', '1')
			else:
				ans[i] = '1' if ans[i + p] == '0' else '0'
		elif ans[i + p] == '.':
			ans[i + p] = '1' if ans[i] == '0' else '0'
	elif ans[i] == '.':
		ans[i] = '0'
f = False
for i in range(n - p):
	if ans[i] != ans[i + p]:
		f = True
if not f:
	print('No')
else:
	print(''.join(ans))


(n, p) = map(int, input().split())
(s, is_equal) = (list(input()), True)
for i in range(n - p):
	if s[i] == s[i + p]:
		if s[i] == '.':
			((s[i], s[i + p]), is_equal) = ('01', False)
			break
	elif s[i] == '.':
		(s[i], is_equal) = (str(1 - int(s[i + p])), False)
		break
	elif s[i + p] == '.':
		(s[i + p], is_equal) = (str(1 - int(s[i])), False)
		break
	else:
		is_equal = False
		break
print('No' if is_equal else ''.join(s).replace('.', '0'))


(n, p) = [int(x) for x in input().split()]
s = input()

def judge():
	if n >= p * 2:
		return True
	if n <= p:
		return False
	for i in range(p, len(s)):
		if s[i] == '.' or s[i - p] == '.' or s[i] != s[i - p]:
			return True
	return False

def main():
	if judge():
		i = 0
		dot = None
		while i < len(s) and (s[i] != '.' or (i - p < 0 and i + p >= len(s))):
			if s[i] == '.':
				print(0, end='')
			else:
				print(s[i], end='')
			i += 1
		if i >= len(s):
			print()
			return ()
		if i - p >= 0:
			if s[i - p] == '0':
				print('1', end='')
			else:
				print('0', end='')
			i += 1
			while i < len(s):
				if s[i] == '0':
					print(0, end='')
				else:
					print(1, end='')
				i += 1
			print()
			return
		elif i + p < len(s):
			if s[i + p] == '0':
				print(1, end='')
			else:
				print(0, end='')
			i += 1
			while i < len(s):
				if s[i] == '0':
					print(0, end='')
				else:
					print(1, end='')
				i += 1
			print()
			return
	else:
		print('No')
main()


(n, p) = map(int, input().split())
s = list(input())
flag = False
t = [''] * n
for i in range(p):
	tmp = []
	one = 0
	zero = 0
	un = 0
	for j in range(i, n, p):
		tmp.append(s[i])
		if s[j] == '.':
			un += 1
		elif s[j] == '1':
			one += 1
		else:
			zero += 1
	if len(tmp) == 1:
		if s[i] == '.':
			s[i] = '1'
		continue
	if zero == 0 and one == 0:
		flag = True
		for j in range(i, n, p):
			if (j - i) // p % 2 == 0:
				s[j] = '1'
			else:
				s[j] = '0'
	elif un >= 1 or zero * one >= 1:
		flag = True
		if zero >= 1:
			for j in range(i, n, p):
				if s[j] == '.':
					s[j] = '1'
		else:
			for j in range(i, n, p):
				if s[j] == '.':
					s[j] = '0'
if flag:
	print(''.join(map(str, s)))
else:
	print('No')


(n, p) = map(int, input().split())
s = list(input())
c = 0
for i in range(0, n - p):
	if s[i] != s[i + p] or (s[i] == '.' and s[i + p] == '.'):
		if s[i] == '.' and s[i + p] == '0':
			s[i] = '1'
		elif s[i] == '.' and s[i + p] == '1':
			s[i] = '0'
		elif s[i] == '1' and s[i + p] == '.':
			s[i + p] = '0'
		elif s[i] == '0' and s[i + p] == '.':
			s[i + p] = '1'
		elif s[i] == '.' and s[i + p] == '.':
			s[i] = '0'
			s[i + p] = '1'
		if not c:
			c = 1
if c:
	if s.count('.') > 0:
		p = s.count('.')
		count = 0
		for i in range(s.index('.'), n):
			if s[i] == '.':
				s[i] = s[i - 1]
				count += 1
			if count >= p:
				break
	print(''.join(s))
else:
	print('No')


import sys
import math
from collections import OrderedDict

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

def iinput():
	return int(input())

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

def listinput():
	return list(map(int, input().split()))
(n, p) = minput()
s = input()
s1 = s[:n - p]
s2 = s[p:]
if s1 == s2 and s1.count('.') == 0 and (s2.count('.') == 0) or n == 1 or n == p:
	print('NO')
else:
	for i in range(n - p):
		if s[i] == '.':
			if s[p + i] == '0' or s[p + i] == '.':
				s = s[:i] + '1' + s[i + 1:]
			else:
				s = s[:i] + '0' + s[i + 1:]
			break
		elif s[p + i] == '.':
			if s[i] == '0' or s[i] == '.':
				s = s[:p + i] + '1' + s[p + i + 1:]
			else:
				s = s[:p + i] + '0' + s[p + i + 1:]
			break
	s = s.replace('.', '0')
	print(s)


(n, p) = map(int, input().split())
ans = n * [0]
s = input()
x = n % p
flag = False
for t in range(p):
	if s[t] == '.':
		if t + p < n:
			if s[t + p] == '0':
				ans[t] = 1
			elif s[t + p] == '1':
				ans[t] = 0
			else:
				ans[t] = 0
			flag = True
		else:
			ans[t] = 0
	else:
		ans[t] = int(s[t])
for t in range(p, n):
	if s[t] == '.':
		flag = True
		if ans[t % p] == 1:
			ans[t] = 0
		else:
			ans[t] = 1
	else:
		ans[t] = int(s[t])
d = ''.join(map(str, ans))
for t in range(n - p):
	if d[t + p] != d[t]:
		flag = True
if flag:
	print(d)
else:
	print('No')


a = [int(i) for i in input().split()]
n = a[0]
p = a[1]
s = str(input())
flag = 0
for i in range(len(s)):
	if i + p < len(s):
		if s[i] != '.' and s[i + p] != '.':
			if s[i] != s[i + p]:
				flag = 1
				break
		elif s[i] == '.' and s[i + p] != '.':
			flag = 1
			if s[i + p] == '1':
				s = s[:i] + '0' + s[i + 1:]
			else:
				s = s[:i] + '1' + s[i + 1:]
			break
		elif s[i] != '.' and s[i + p] == '.':
			flag = 1
			if s[i] == '1':
				s = s[:i + p] + '0' + s[i + 1 + p:]
			else:
				s = s[:i + p] + '1' + s[i + 1 + p:]
			break
		else:
			flag = 1
			s = s[:i] + '1' + s[i + 1:]
			s = s[:i + p] + '0' + s[i + 1 + p:]
			break
if flag == 0:
	print('No')
else:
	for i in range(len(s)):
		if s[i] == '.':
			s = s[:i] + '0' + s[i + 1:]
	print(s)


class CodeforcesTask989BSolution:

	def __init__(self):
		self.result = ''
		self.n_p = []
		self.records = []

	def read_input(self):
		self.n_p = [int(x) for x in input().split(' ')]
		self.records = list(input())

	def process_task(self):
		fixed = True
		for x in range(self.n_p[0] - self.n_p[1]):
			if self.records[x + self.n_p[1]] == '.' and self.records[x] == '.':
				self.records[x] = '1'
				self.records[x + self.n_p[1]] = '0'
				fixed = False
				break
			if self.records[x + self.n_p[1]] == '.':
				self.records[x + self.n_p[1]] = '1' if self.records[x] == '0' else '0'
				fixed = False
				break
			if self.records[x] == '.':
				self.records[x] = '1' if self.records[x + self.n_p[1]] == '0' else '0'
				fixed = False
				break
			if self.records[x] == '1' and self.records[x + self.n_p[1]] == '0':
				fixed = False
				break
			if self.records[x] == '0' and self.records[x + self.n_p[1]] == '1':
				fixed = False
				break
		if not fixed:
			self.result = ''.join(self.records).replace('.', '0')
		else:
			self.result = 'No'

	def get_result(self):
		return self.result
Solution = CodeforcesTask989BSolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


(n, p) = [int(i) for i in input().strip().split(' ')]
s = [i for i in input().strip()]
i = 0
is_not_p = False
while i < n - p:
	if s[i] != s[i + p] or s[i] == '.' or s[i + p] == '.':
		if s[i] == '.':
			s[i] = '0' if s[i + p] == '1' else '1'
		if s[i + p] == '.':
			s[i + p] = '0' if s[i] == '1' else '1'
		is_not_p = True
		break
	i += 1
if not is_not_p:
	print('No')
else:
	while i < n:
		if s[i] == '.':
			s[i] = '0'
		i += 1
	print(''.join(s))


(n, p) = map(int, input().split())
s = list(input())

def clean(start):
	for j in range(start, len(s)):
		if s[j] == '.':
			s[j] = '0'
	print(''.join(s))
	exit()
for i in range(len(s) - p):
	si = s[i]
	ip = i + p
	sip = s[ip]
	if si == '0':
		if sip == '1':
			clean(i + 1)
		elif sip == '.':
			s[ip] = '1'
			clean(i + 1)
	elif si == '1':
		if sip == '0':
			clean(i + 1)
		elif sip == '.':
			s[ip] = '0'
			clean(i + 1)
	elif sip == '0':
		s[i] = '1'
		clean(i + 1)
	elif sip == '1':
		s[i] = '0'
		clean(i + 1)
	else:
		s[i] = '0'
		s[ip] = '1'
		clean(i + 1)
print('No')


(n, p) = map(int, input().strip().split())
tide = input().strip()
flag = 0
l_tide = list(tide)
rev = {'0': '1', '1': '0'}
for i in range(n - p):
	if l_tide[i] == '.':
		if l_tide[i + p] == '.':
			l_tide[i] = '0'
			l_tide[i + p] = '1'
			tide_str = ''.join(l_tide)
			tide_str = tide_str.replace('.', '0')
			flag = 1
			print(tide_str)
			break
		else:
			l_tide[i] = rev[l_tide[i + p]]
			tide_str = ''.join(l_tide)
			tide_str = tide_str.replace('.', '0')
			flag = 1
			print(tide_str)
			break
	elif l_tide[i + p] == '.':
		l_tide[i + p] = rev[l_tide[i]]
		tide_str = ''.join(l_tide)
		tide_str = tide_str.replace('.', '0')
		flag = 1
		print(tide_str)
		break
	elif l_tide[i] == rev[l_tide[i + p]]:
		tide_str = ''.join(l_tide)
		tide_str = tide_str.replace('.', '0')
		flag = 1
		print(tide_str)
		break
	else:
		continue
if flag == 0:
	print('No')


(n, p) = map(int, input().split())
s = list(input())
r = 0
for i in range(n):
	if s[i] == '.':
		if i + p < n and s[i + p] == '0':
			s[i] = '1'
		elif i - p >= 0 and s[i - p] == '0':
			s[i] = '1'
		else:
			s[i] = '0'
if any((s[i] != s[i + p] for i in range(n - p))):
	print(''.join(s).replace('.', '0'), sep='')
else:
	print('No')


(n, m) = [int(nn) for nn in input().split()]
str = list(input())
p = 0
for i in range(n - m):
	j = i + m
	if j >= n:
		break
	if str[i] != '.' and str[j] != '.':
		if str[i] != str[j]:
			p = 1
	elif str[i] == '.' and str[j] == '.':
		p = 1
		str[i] = '1'
		str[j] = '0'
	else:
		p = 1
		if str[i] == '1':
			str[j] = '0'
		elif str[i] == '0':
			str[j] = '1'
		elif str[j] == '1':
			str[i] = '0'
		else:
			str[i] = '1'
if p == 1:
	for i in range(n):
		if str[i] == '.':
			str[i] = '0'
	print(''.join(str))
else:
	print('No')


(n, p) = [int(item) for item in input().split()]
s = list(input())
no = True
for i in range(n - p):
	if s[i] == '.' and s[i + p] == '.':
		s[i] = '0'
		s[i + p] = '1'
	elif s[i] != '.' and s[i + p] != '.':
		if s[i] != s[i + p]:
			no = False
		continue
	elif s[i] != '.':
		s[i + p] = str(int(s[i]) ^ 1)
	elif s[i + p] != '.':
		s[i] = str(int(s[i + p]) ^ 1)
	no = False
for i in range(n):
	if s[i] == '.':
		s[i] = '0'
if no:
	print('No')
else:
	print(''.join(s))


(n, m) = map(int, input().split())
s = input()
h = s
k = s[:m]
s = s[m:]
count = 1
result = ''
while s.find(k) >= 0 and len(s) > m:
	s = s[m:]
	count += 1
check = False
for i in range(min(len(k), len(s))):
	if k[i] != s[i]:
		check = True
		if s[i] == '.':
			mid = k[i]
			dk = 's'
		else:
			dk = 'k'
			mid = s[i]
		t = i
		break
if check == False:
	if s.count('.') == 0:
		if m == 1 and n > 1:
			result = k.replace('.', '0', 1) + h[m:]
			result = result.replace('.', '1')
			print(result)
		else:
			print('NO')
	else:
		result = k.replace('.', '0') + h[m:].replace('.', '1')
		print(result)
else:
	if mid == '0':
		if dk == 's':
			result = h[:m] * count + s.replace('.', '1', 1)
		else:
			result = k.replace('.', '1', 1) + h[m:]
	elif dk == 's':
		result = h[:m] * count + s.replace('.', '0', 1)
	else:
		result = k.replace('.', '0', 1) + h[m:]
	result = result.replace('.', '0')
	print(result)


(n, p) = map(int, input().split())
s = list(input())
pos = []
for i in range(n):
	if i + p < n:
		if s[i] != s[i + p] and s[i] != '.' and (s[i + p] != '.'):
			pos.append(i)
		if s[i] == '.' or s[i + p] == '.':
			pos.append(i)
	else:
		break
if len(pos) == 0:
	print('No')
	exit()
cnt = 0
for i in range(n):
	if i == pos[cnt]:
		cnt += 1
		cnt %= len(pos)
		if s[i + p] == '.':
			if s[i] == '1':
				s[i + p] = '0'
			elif s[i] == '0':
				s[i + p] = '1'
			else:
				s[i + p] = '1'
				s[i] = '0'
		elif s[i] == '.':
			if s[i + p] == '1':
				s[i] = '0'
			elif s[i + p] == '0':
				s[i] = '1'
			else:
				s[i + p] = '1'
				s[i] = '0'
	elif s[i] == '.':
		s[i] = '0'
print(''.join(s))


from sys import stdin, stdout
(n, p) = map(int, stdin.readline().split())
ans = list(stdin.readline().strip())
for i in range(n - p):
	if ans[i] != '.' and ans[i + p] != '.':
		continue
	if ans[i] != '.' and ans[i + p] == '.':
		if ans[i] == '1':
			ans[i + p] = '0'
		else:
			ans[i + p] = '1'
	elif ans[i] == '.' and ans[i + p] == '.':
		(ans[i], ans[i + p]) = ('1', '0')
	elif ans[i + p] == '1':
		ans[i] = '0'
	else:
		ans[i] = '1'
ans = ''.join(ans).replace('.', '1')
label = 0
for i in range(n - p):
	if ans[i] != ans[i + p]:
		label = 1
if not label:
	stdout.write('No')
else:
	stdout.write(''.join(ans))


(n, k) = map(int, input().split())
s = list(str(input()))
flag = 0
for i in range(n):
	if i >= k:
		if s[i] == '.':
			s[i] = '1' if s[i - k] == '0' else '0'
			flag = 1
		elif s[i] != s[i - k]:
			flag = 1
	elif s[i] == '.':
		if i + k < n:
			if s[i + k] == '0' or s[i + k] == '.':
				s[i] = '1'
			else:
				s[i] = '0'
			flag = 1
		else:
			s[i] = '1'
if flag == 1:
	print(''.join(s))
else:
	print('NO')


(n, p) = map(int, input().split())
s = input()
sep = len(s) - p
s1 = list(s[0:sep])
s2 = list(s[sep:p])
s3 = list(s[p:len(s)])
if s1 == s3 and '.' not in s1:
	print('No')
	exit(0)
for (i, ch) in enumerate(s1):
	if s1[i] == s3[i]:
		if s1[i] == '.':
			s1[i] = '1'
			s3[i] = '0'
	elif s1[i] == '.':
		if s3[i] == '0':
			s1[i] = '1'
		else:
			s1[i] = '0'
	elif s3[i] == '.':
		if s1[i] == '0':
			s3[i] = '1'
		else:
			s3[i] = '0'
if s2 == []:
	ans = s1 + s3[len(s1) - p:]
else:
	ans = s1 + s2 + s3
for (i, ch) in enumerate(ans):
	if ch == '.':
		ans[i] = '0'
print(''.join(ans))


(stfn, stfp) = input().split()
(n, p) = (int(stfn), int(stfp))
s = list(str(input()))
corrected = False
for i in range(0, n - p):
	if corrected:
		if s[i] == '.':
			s[i] = '1'
		if s[i + p] == '.':
			s[i + p] = '0'
	elif s[i] == '.':
		if s[i + p] == '.':
			s[i] = '0'
			s[i + p] = '1'
			corrected = True
		elif s[i + p] == '1':
			s[i] = '0'
			corrected = True
		elif s[i + p] == '0':
			s[i] = '1'
			corrected = True
	elif s[i] == '1':
		if s[i + p] == '.':
			s[i + p] = '0'
			corrected = True
		elif s[i + p] == '1':
			continue
		elif s[i + p] == '0':
			corrected = True
	elif s[i] == '0':
		if s[i + p] == '.':
			s[i + p] = '1'
			corrected = True
		elif s[i + p] == '0':
			continue
		elif s[i + p] == '1':
			corrected = True
if corrected:
	for j in range(i + 1, p):
		if s[j] == '.':
			s[j] = '1'
	print(''.join(s))
else:
	print('No')


(n, p) = map(int, input().split())
s = input()
A = [list() for i in range(p)]
for i in range(len(s)):
	A[i % p].append(s[i])
bad_index = -1
change = False
change1 = '0'
change2 = '0'
for i in range(p):
	if '.' in A[i] and A[i] != ['.']:
		bad_index = i
		change = True
		if '0' in A[i]:
			change1 = '1'
			change2 = '0'
		else:
			change1 = '0'
			change2 = '1'
	if '0' in A[i] and '1' in A[i]:
		bad_index = i
		change = False
if bad_index == -1:
	print('No')
else:
	ans = list(s)
	cnt = 0
	for i in range(len(s)):
		if i % p == bad_index:
			if not change:
				if s[i] == '.':
					ans[i] = '0'
			if change:
				if s[i] == '.':
					if cnt == 0:
						ans[i] = change1
						cnt += 1
					else:
						ans[i] = change2
		elif s[i] == '.':
			ans[i] = change1
	print(''.join(ans))


def joinalist(ns):
	s = ''.join(ns)
	return s

def properize(s, n):
	ns = list(s)
	for i in range(n):
		if ns[i] == '.':
			ns[i] = '0'
	return joinalist(ns)

def isThere(s, n, p):
	ns = list(s)
	for i in range(p, n):
		a = ns[i - p]
		b = ns[i]
		if b == '.':
			if a == '.':
				ns[i - p] = '1'
				ns[i] = '0'
				return joinalist(ns)
			elif a == '1':
				ns[i] = '0'
				return joinalist(ns)
			else:
				ns[i] = '1'
				return joinalist(ns)
		elif b == '0':
			if a == '.':
				ns[i - p] = '1'
				return joinalist(ns)
			elif a == '0':
				continue
			else:
				return joinalist(ns)
		elif a == '.':
			ns[i - p] = '0'
			return joinalist(ns)
		elif a == '1':
			continue
		else:
			return joinalist(ns)
	return 0
n_p = input()
np = n_p.split(' ')
n = int(np[0])
p = int(np[1])
s = input()
ns = isThere(s, n, p)
if ns == 0:
	print('No')
else:
	print(properize(ns, n))


(n, p) = map(int, input().split())
string_input1 = input()
string_input = list(string_input1)
flag = 0
for i in range(len(string_input) - p):
	if string_input[i] != string_input[i + p] or (string_input[i] == '.' and string_input[i + p] == '.'):
		flag = 1
		if string_input[i] == '.':
			if string_input[i + p] == '0':
				string_input[i] = '1'
			else:
				string_input[i] = '0'
		if string_input[i + p] == '.':
			if string_input[i] == '0':
				string_input[i + p] = '1'
			else:
				string_input[i + p] = '0'
	else:
		continue
str1 = ''.join(string_input)
if str1 == string_input1 and flag == 0:
	print('No')
else:
	str1 = str1.replace('.', '0')
	print(str1)


(n, a) = map(int, input().split())
A = input()
dd = 2
for i in range(n - a):
	if A[i] == A[i + a]:
		if A[i] == '.':
			A = A[:i] + '1' + A[i + 1:]
			A = A[:i + a] + '0' + A[i + a + 1:]
			dd = 5
			break
		else:
			dd = 2
	else:
		if A[i] == '.':
			if A[i + a] == '0':
				A = A[:i] + '1' + A[i + 1:]
			elif A[i + a] == '1':
				A = A[:i] + '0' + A[i + 1:]
		if A[i + a] == '.':
			if A[i] == '0':
				A = A[:i + a] + '1' + A[i + a + 1:]
			elif A[i] == '1':
				A = A[:i + a] + '0' + A[i + a + 1:]
		dd = 5
		break
if dd == 2:
	print('No')
else:
	for i in range(n):
		if A[i] == '.':
			print(1, end='')
		else:
			print(A[i], end='')


(a, b) = map(int, input().split())
lkl = list(input())
n = 0
for i in range(a):
	if i + b < a:
		if lkl[i] != lkl[i + b]:
			n = 1
			if lkl[i] == '.':
				lkl[i] = str((int(lkl[i + b]) + 1) % 2)
			elif lkl[i + b] == '.':
				lkl[i + b] = str((int(lkl[i]) + 1) % 2)
		elif lkl[i] == '.':
			n = 1
			lkl[i] = '1'
			lkl[i + b] = '0'
	elif lkl[i] == '.':
		lkl[i] = str(1)
if n == 0:
	print('No')
else:
	print(''.join(lkl))


n = [int(num) for num in input().split()]
s = input()
flag = 0
for i in range(0, n[0] - n[1]):
	if s[i] != s[i + n[1]] and s[i] != '.' and (s[i + n[1]] != '.'):
		flag = 1
		break
	elif s[i] == s[i + n[1]] and s[i] == '.':
		s = s[:i] + '0' + s[i + 1:i + n[1]] + '1' + s[i + n[1] + 1:]
		flag = 1
		break
	elif s[i] == '.':
		if s[i + n[1]] == '1':
			s = s[:i] + '0' + s[i + 1:]
		else:
			s = s[:i] + '1' + s[i + 1:]
		flag = 1
		break
	elif s[i + n[1]] == '.':
		if s[i] == '1':
			s = s[:i + n[1]] + '0' + s[i + n[1] + 1:]
		else:
			s = s[:i + n[1]] + '1' + s[i + n[1] + 1:]
		flag = 1
		break
if flag == 1:
	for i in s:
		if i == '.':
			i = '0'
		print(i, end='')
else:
	print('NO')


def deal():
	for i in range(len(seq)):
		if seq[i] == '.':
			seq[i] = '0'
	print(''.join(seq[::-1]))
(n, p) = map(int, input().split())
seq = list(input()[::-1])
result = False
for i in range(len(seq) - p):
	if seq[i] == '.':
		if seq[i + p] == '0':
			seq[i] = '1'
		elif seq[i + p] == '1':
			seq[i] = '0'
		else:
			seq[i] = '0'
			seq[i + p] = '1'
		deal()
		result = True
		break
	elif seq[i] != seq[i + p]:
		if seq[i + p] == '.':
			if seq[i] == '1':
				seq[i + p] = '0'
			else:
				seq[i + p] = '1'
		deal()
		result = True
		break
if result == False:
	print('No')


import sys
(n, p) = map(int, sys.stdin.readline().split())
s = sys.stdin.readline().strip()
res = 'No'
cnt = dict()
for start in range(p):
	cnt['0'] = 0
	cnt['1'] = 0
	cnt['.'] = 0
	id1 = -1
	id2 = -1
	for i in range(start, n, p):
		cnt[s[i]] += 1
		if s[i] == '.':
			if id1 == -1:
				id1 = i
			else:
				id2 = i
	if cnt['0'] > 0 and cnt['1'] + cnt['.'] > 0:
		res = s.replace('.', '1')
		break
	if cnt['1'] > 0 and cnt['0'] + cnt['.'] > 0:
		res = s.replace('.', '0')
		break
	if cnt['.'] > 1:
		res = s[:id1] + '0' + s[id1 + 1:id2] + '1' + s[id2 + 1:]
		res = res.replace('.', '0')
		break
print(res)


(n, p) = map(int, input().split())
s = input()
t = [int(i) for i in s.replace('.', '0')]
if all((t[i] == t[i + p] for i in range(n - p))):
	(x, y) = (s[:n - p].find('.'), s[p:].find('.'))
	if x != -1:
		t[x] = t[x + p] ^ 1
	elif y != -1:
		t[y + p] = t[y] ^ 1
	else:
		print('No')
		exit()
for item in t:
	print(item, end='')


import sys
import math
from collections import defaultdict
(n, p) = map(int, sys.stdin.readline().split())
s = list(sys.stdin.readline()[:-1])
(l, r) = (0, p)
(ansl, ansr) = (-1, -1)
while r < n:
	if s[l] == '.' and s[r] == '.':
		s[l] = '0'
		s[r] = '1'
		(ansl, ansr) = (l, r)
		break
	elif s[l] == '.' and s[r] == '0':
		s[l] = '1'
		(ansl, ansr) = (l, r)
		break
	elif s[l] == '.' and s[r] == '1':
		s[l] = '0'
		(ansl, ansr) = (l, r)
		break
	elif s[l] == '1' and s[r] == '.':
		s[r] = '0'
		(ansl, ansr) = (l, r)
		break
	elif s[l] == '0' and s[r] == '.':
		s[r] = '1'
		(ansl, ansr) = (l, r)
		break
	elif int(s[l]) ^ int(s[r]) == 1:
		(ansl, ansr) = (l, r)
		break
	r += 1
	l += 1
for i in range(ansl):
	if s[i] == '.':
		s[i] = '0'
for i in range(ansl + 1, ansr):
	if s[i] == '.':
		s[i] = '0'
for i in range(ansr + 1, n):
	if s[i] == '.':
		s[i] = '0'
if ansl == ansr == -1:
	print('No')
	sys.exit()
else:
	print(''.join((x for x in s)))


import sys
(n, p) = map(int, sys.stdin.readline().split())
st = sys.stdin.readline()
flag = 0
stl = list(st)
for i in range(0, len(st)):
	if i < n - p and stl[i] == '.':
		if stl[i + p] == '0':
			stl[i] = '1'
		elif stl[i + p] == '1':
			stl[i] = '0'
		else:
			stl[i] = '0'
			stl[i + p] = '1'
	elif i < n - p and stl[i + p] == '.':
		if stl[i] == '0':
			stl[i + p] = '1'
		else:
			stl[i + p] = '0'
	elif i >= n - p and stl[i] == '.':
		stl[i] = '0'
res = ''.join(stl)
for i in range(0, n - p):
	if stl[i] != stl[i + p]:
		flag = 1
		break
if flag == 0:
	print('No')
else:
	print(res)


(n, p) = map(int, input().split())
s = list(input())
c = 0
for i in range(0, n - p):
	(a, b) = (0, 0)
	if s[i] == '.':
		a = 1
	if s[i + p] == '.':
		b = 1
	if s[i] == s[i + p] and a + b == 0:
		c += 1
if c == n - p:
	print('No')
else:
	for i in range(0, n - p):
		(a, b) = (0, 0)
		if s[i] == '.':
			a = 1
		if s[i + p] == '.':
			b = 1
		if a + b == 2:
			s[i] = '1'
			s[i + p] = '0'
		if a + b == 0:
			continue
		elif a == 1:
			if s[i + p] == '0':
				s[i] = '1'
			else:
				s[i] = '0'
		elif s[i] == '0':
			s[i + p] = '1'
		else:
			s[i + p] = '0'
	for i in range(0, n):
		if s[i] == '.':
			s[i] = '0'
	print(''.join(s))


(n, p) = map(int, input().split(' '))
cad = input()
i = 0
j = p
notp = False
while i < n and j < n:
	if cad[i] == '1' and cad[j] == '1' or (cad[i] == '0' and cad[j] == '0'):
		i += 1
		j += 1
	elif cad[i] == '1' and cad[j] == '0':
		print(cad.replace('.', '0'))
		notp = True
		break
	elif cad[i] == '0' and cad[j] == '1':
		print(cad.replace('.', '0'))
		notp = True
		break
	elif cad[i] == '.':
		notp = True
		listcad = list(cad)
		if cad[j] == '.':
			listcad[i] = '1'
			listcad[j] = '0'
			cad = ''.join(listcad)
			print(cad.replace('.', '0'))
		elif cad[j] == '1':
			print(cad.replace('.', '0'))
		else:
			print(cad.replace('.', '1'))
		break
	elif cad[j] == '.':
		notp = True
		listcad = list(cad)
		if cad[i] == '.':
			listcad[j] = '1'
			listcad[i] = '0'
			cad = ''.join(listcad)
			print(cad.replace('.', '0'))
		elif cad[i] == '1':
			print(cad.replace('.', '0'))
		else:
			print(cad.replace('.', '1'))
		break
if not notp:
	print('No')


(n, p) = map(int, input().split())
s = input()
for i in range(n - p):
	(c1, c2) = (s[i], s[i + p])
	if c1 != c2:
		if c1 == '.':
			c3 = c2
		else:
			c3 = c1
		if c3 == '0':
			c3 = '1'
		else:
			c3 = '0'
		print(s.replace('.', c3))
		break
	elif c1 == '.':
		s = s.replace(c1, '0')
		print(s[:i] + '1' + s[i + 1:])
		break
else:
	print('No')


(n, p) = map(int, input().split())
s = input()
a = [[]]
i = 0
for c in s:
	if i == p:
		i = 0
		a.append([])
	a[-1].append(c)
	i += 1
while len(a[-1]) < p:
	a[-1].append('.')
al = len(a)
for j in range(p):
	found = set()
	for i in range(al):
		found.add(a[i][j])
	if '0' in found and '1' in found:
		for i in range(al):
			if a[i][j] == '.':
				a[i][j] = '0'
	elif '.' in found:
		if len(found) > 1:
			found.remove('.')
			this = found.pop()
			that = '1' if this == '0' else '0'
			for i in range(al):
				if a[i][j] == '.':
					a[i][j] = that
		else:
			a[0][j] = '0'
			for i in range(1, al):
				a[i][j] = '1'
result = ''
for i in range(al):
	result += ''.join(a[i])
result = result[:n]
has_p = 1
for i in range(p):
	b = set()
	for j in range(i, n, p):
		b.add(result[j])
	if len(b) > 1:
		has_p = 0
if has_p:
	print('No')
else:
	print(result)


import time
(n, p) = (int(i) for i in input().split())
s = list(input())
start = time.time()
l = ['.' for i in range(p)]
ans = 'No'
if p < n:
	j = 0
	for i in range(n):
		if s[i] != '.':
			if l[j] != '.' and l[j] != s[i]:
				ans = 'Yes'
			else:
				l[j] = s[i]
		j += 1
		if j == p:
			j = 0
	j = 0
	for i in range(n):
		if s[i] == '.' and l[j] != '.':
			if l[j] == '0':
				s[i] = '1'
			elif l[j] == '1':
				s[i] = '0'
			ans = 'Yes'
			break
		j += 1
		if j == p:
			j = 0
	flag = 0
	for i in range(p):
		if s[i] == '.':
			s[i] = '1'
	for i in range(p, n):
		if s[i] == '.':
			flag = 1
			s[i] = '0'
	if flag == 1:
		ans = 'Yes'
if ans == 'Yes':
	for i in range(n):
		print(s[i], end='')
	print()
else:
	print(ans)
finish = time.time()


(n, p) = map(int, input().split())
s = input()
i = 0
flag = 0
while i < len(s) - p:
	if s[i] != s[i + p] or s[i] == s[i + p] == '.':
		flag = 1
		if s[i] == s[i + p]:
			s = s[:i] + '0' + s[i + 1:i + p] + '1' + s[i + p + 1:]
		elif s[i] == '.':
			if s[i + p] == '1':
				s = s[:i] + '0' + s[i + 1:]
			else:
				s = s[:i] + '1' + s[i + 1:]
		elif s[i + p] == '.':
			if s[i] == '1':
				s = s[:i + p] + '0' + s[i + p + 1:]
			else:
				s = s[:i + p] + '1' + s[i + p + 1:]
		i += 1
		while i < len(s):
			if s[i] == '.':
				s = s[:i] + '0' + s[i + 1:]
			i += 1
	i += 1
if flag == 1:
	print(s)
else:
	print('No')


(n, m) = map(int, input().split())
l = list(input())
T = 1
for i in range(n - m):
	if l[0 + i] == l[m + i] and l[0 + i] != '.':
		T = 5
	elif l[0 + i] == l[m + i] and l[0 + i] == '.':
		l[0 + i] = '0'
		l[m + i] = '1'
		T = 0
		break
	elif l[0 + i] == '.' and l[m + i] == '0':
		l[0 + i] = '1'
		T = 0
		break
	elif l[0 + i] == '.' and l[m + i] == '1':
		l[0 + i] = '0'
		T = 0
		break
	elif l[m + i] == '.' and l[0 + i] == '0':
		l[m + i] = '1'
		T = 0
		break
	elif l[m + i] == '.' and l[0 + i] == '1':
		l[m + i] = '0'
		T = 0
		break
	elif l[0 + i] != l[m + i]:
		T = 0
		break
if T:
	print('No')
	exit()
for i in range(n):
	if l[i] == '.':
		l[i] = '0'
print(''.join(l))


def print_result(s):
	for i in range(0, len(s)):
		if s[i] == '.':
			s[i] = 0
	print(''.join(map(str, s)))

def solution(n, p, s):
	for i in range(0, len(s) - p):
		if s[i] == '0':
			if s[i + p] != '0':
				if s[i + p] == '.':
					s[i + p] = '1'
				print_result(s)
				return
		elif s[i] == '1':
			if s[i + p] != '1':
				if s[i + p] == '.':
					s[i + p] = '0'
				print_result(s)
				return
		else:
			if s[i + p] == '1':
				s[i] = '0'
			elif s[i + p] == '0':
				s[i] = '1'
			else:
				s[i] = '0'
				s[i + p] = '1'
			print_result(s)
			return
	print('No')
	return
(n, p) = input().split()
n = int(n)
p = int(p)
s = list(input())
solution(n, p, s)


from sys import stdin, stdout
nmbr = lambda : int(stdin.readline())
lst = lambda : list(map(int, stdin.readline().split()))
for _ in range(1):
	(n, p) = lst()
	s = list(input())
	f = 0
	for i in range(n - p):
		if s[i] == s[i + p] == '.':
			s[i] = '1'
			s[i + p] = '0'
			f = 1
			break
		if s[i] != '.' and s[i + p] != '.' and (s[i] != s[i + p]):
			f = 1
			break
		elif s[i] == '.' and s[i + p] != '.':
			s[i] = '1' if s[i + p] == '0' else '0'
			f = 1
			break
		elif s[i] != '.' and s[i + p] == '.':
			s[i + p] = '1' if s[i] == '0' else '0'
			f = 1
			break
	if f:
		for i in range(n):
			if s[i] == '.':
				s[i] = '1'
	print('No' if f == 0 else ''.join(s))


import sys
(n, p) = map(int, sys.stdin.readline().split())
s = list(sys.stdin.readline().strip())
for i in range(p):
	l = [s[j] for j in range(i, n, p)]
	if '0' in l and '1' in l:
		print(''.join(s).replace('.', '0'))
		sys.exit(0)
	elif set(l) == set(['.']) and len(l) >= 2:
		s[i] = '0'
		s[i + p] = '1'
		print(''.join(s).replace('.', '0'))
		sys.exit(0)
	elif len(set(l)) == 2:
		if '0' in l:
			print(''.join(s).replace('.', '1'))
		else:
			print(''.join(s).replace('.', '0'))
		sys.exit(0)
print('No')


(n, m) = map(int, input().split())
s = list(input())
l = len(s)
f = False
for i in range(l - m):
	if not (s[i] == s[i + m] and (s[i] != '.' and s[i + m] != '.')):
		f = True
		if s[i] == '.':
			if s[i + m] == '1':
				s[i] = '0'
			else:
				s[i] = '1'
		if s[i + m] == '.':
			if s[i] == '0':
				s[i + m] = '1'
			else:
				s[i + m] = '0'
if f == False:
	print('No')
	quit()
for i in range(len(s)):
	if s[i] == '.':
		s[i] = '0'
print(''.join(s))


int_inp = lambda : int(input())
strng = lambda : input().strip()
strl = lambda : list(input().strip())
mul = lambda : map(int, input().split())
mulf = lambda : map(float, input().split())
seq = lambda : list(map(int, input().split()))
import math
from collections import Counter, defaultdict
(a, b) = mul()
m = list(input())
for i in range(a):
	if m[i] == '.':
		try:
			if m[i + b] == '1':
				m[i] = '0'
				k = ''.join(m)
				k = k.replace('.', '0')
				break
			elif m[i + b] == '0':
				m[i] = '1'
				k = ''.join(m)
				k = k.replace('.', '0')
				break
			else:
				m[i + b] = '1'
				m[i] = '0'
				k = ''.join(m)
				k = k.replace('.', '0')
				break
		except:
			print('no')
			exit()
	elif m[i] != '.':
		try:
			if m[i + b] == m[i]:
				continue
			elif m[i + b] == '.':
				m[i + b] = str(1 - int(m[i]))
				k = ''.join(m)
				k = k.replace('.', '0')
				break
			else:
				k = ''.join(m)
				k = k.replace('.', '0')
				break
		except:
			print('no')
			exit()
print(k)


(n, p) = map(int, input().split())
s = input()
flag = 0
for i in range(len(s) - p):
	if flag == 1:
		break
	for j in range(i + p, len(s), p):
		if s[i] == '.' and s[j] == '.':
			s = s[:i] + '0' + s[i + 1:]
			s = s[:j] + '1' + s[j + 1:]
			flag = 1
			break
		elif s[i] != '.' and s[j] != '.' and (s[i] != s[j]):
			flag = 1
			break
		elif s[i] == '.' and s[j] != '.':
			ch = (1 + int(s[j])) % 2
			s = s[:i] + str(ch) + s[i + 1:]
			flag = 1
			break
		elif s[i] != '' and s[j] == '.':
			ch = (1 + int(s[i])) % 2
			s = s[:j] + str(ch) + s[j + 1:]
			flag = 1
			break
if flag == 0:
	print('No')
else:
	for i in range(len(s)):
		if s[i] == '.':
			s = s[:i] + '1' + s[i + 1:]
	print(s)


import re
readin = input()
readin_list = re.split('[ ]', readin)
readin_list = list(map(int, readin_list))
readin = input()
readin_str = list(readin)
sta_dict = {'0': '1', '1': '0'}
fin_ans = False
for idx in range(0, readin_list[1]):
	multi_val = 1
	while multi_val * readin_list[1] + idx < len(readin_str):
		pos_now = multi_val * readin_list[1] + idx
		modi_signal = False
		if readin_str[pos_now] != readin_str[idx]:
			fin_ans = True
			if readin_str[pos_now] == '.' or readin_str[idx] == '.':
				modi_signal = True
		elif readin_str[pos_now] == '.' and readin_str[idx] == '.':
			fin_ans = True
			readin_str[idx] = '0'
			modi_signal = True
		if modi_signal == True:
			if readin_str[pos_now] == '.':
				readin_str[pos_now] = sta_dict[readin_str[idx]]
			else:
				readin_str[idx] = sta_dict[readin_str[pos_now]]
		multi_val += 1
if fin_ans == False:
	print('No')
else:
	for idx in range(0, readin_list[0]):
		if readin_str[idx] == '.':
			readin_str[idx] = '0'
	fin_str = ''.join(readin_str)
	print(fin_str)


(n, p) = map(int, input().split())
s = input()
for i in range(n):
	if i + p >= n:
		continue
	if s[i] == '.' or s[i + p] == '.' or s[i] != s[i + p]:
		was_lol = s[i] == '.'
		s = s.replace('.', '0')
		if s[i] == s[i + p]:
			if was_lol:
				s = s[:i] + '1' + s[i + 1:]
			else:
				s = s[:i + p] + '1' + s[i + p + 1:]
		print(s)
		break
else:
	print('No')