Read problems statements in [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well.

Lately, Chef has been inspired by the "pawri" meme. Therefore, he decided to take a string $S$ and change each of its substrings that spells "party" to "pawri". Find the resulting string.

------  Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains a single string $S$.

------  Output ------
For each test case, print a single line containing the string after it is modified by Chef.

------  Constraints ------
$1 ≤ T ≤ 10$
$1 ≤ |S| ≤ 10^{5}$
$S$ contains only lowercase English letters

----- Sample Input 1 ------ 
3

part

partypartiparty

yemaihuyemericarhaiauryahapartyhorahihai
----- Sample Output 1 ------ 
part

pawripartipawri

yemaihuyemericarhaiauryahapawrihorahihai
----- explanation 1 ------ 
Example case 1: There is no substring "party" in the original string.

Example case 2: The original string has $2$ substrings "party".

Example case 3: There is only a single substring "party" in the original string.

Difficulty: EASY
Tags: String algorithms

Data structures

Implementation
Skill types: Data structures

Starter code:

Solutions:
for i in range(int(input())):
	s = input()
	s = s.replace('party', 'pawri')
	print(s)


n = int(input())
for i in range(n):
	x = input()
	if 'party' in x:
		y = x.replace('party', 'pawri')
		print(y)
	else:
		print(x)


for _ in range(int(input())):
	s = input()
	s1 = s.replace('party', 'pawri')
	print(s1)


for _ in range(int(input())):
	x = input()
	y = x.count('party')
	if 'party' in x:
		z = x.replace('party', 'pawri')
		print(z)
	elif 'party ' not in x:
		print(x)


for _ in range(int(input())):
	s = input()
	str = 'party'
	str1 = 'pawri'
	for i in str:
		if i in s:
			r = s.replace('party', 'pawri')
			print(r)
			break
	else:
		print(s)


n = int(input())
s = 'party'
for i in range(n):
	l = input()
	if s in l:
		t = l.replace('party', 'pawri')
		print(t)
	else:
		print(l)


n = int(input())
for i in range(n):
	a = input()
	i = 0
	c = 0
	if 'party' in a:
		a = a.replace('party', 'pawri')
		print(a)
	else:
		print(a)


for _ in range(int(input())):
	s = input()
	if 'party' in s:
		r = s.replace('party', 'pawri')
		print(r)
	else:
		print(s)


n = int(input())
for i in range(0, n):
	a = input()
	a = a.replace('party', 'pawri')
	print(a)


t = int(input())
for i in range(t):
	s = input()
	string = s.replace('party', 'pawri')
	print(string)


p = int(input())
for i in range(p):
	s = input()
	if 'party' in s:
		r = s.replace('party', 'pawri')
		print(r)
	else:
		print(s)


t = int(input())
for _ in range(t):
	string = input()
	s = list(map(str, string))
	for i in range(len(s) - 4):
		if s[i] == 'p' and s[i + 1] == 'a' and (s[i + 2] == 'r') and (s[i + 3] == 't') and (s[i + 4] == 'y'):
			s[i + 2] = 'w'
			s[i + 3] = 'r'
			s[i + 4] = 'i'
			i += 5
	print(''.join(s))


for i in range(int(input())):
	s = input()
	a = [i for i in s]
	if len(s) < 5:
		print(s)
	else:
		for i in range(len(s) - 4):
			if s[i:i + 5] == 'party':
				a[i:i + 5] = ['p', 'a', 'w', 'r', 'i']
		for i in a:
			print(i, end='')
		print()


for i in range(int(input())):
	a = input()
	if 'party' in a:
		x = a.replace('party', 'pawri')
		print(x)
	else:
		print(a)


t = int(input())
for _ in range(t):
	s = input()
	if 'party' in s:
		s = s.replace('party', 'pawri')
	print(s)


import re
for _ in range(int(input())):
	s = input()
	s = re.sub('party', 'pawri', s)
	print(s)


for t in range(int(input())):
	s = input()
	k = s.replace('party', 'pawri')
	print(k)


n = int(input())
v = 'party'
for i in range(n):
	l = input()
	if v in l:
		r = l.replace('party', 'pawri')
		print(r)
	else:
		print(l)


for _ in range(int(input())):
	string = input()
	string = string.replace('party', 'pawri')
	print(string)


tc = int(input())
for i in range(tc):
	s = input()
	a = list(s)
	if len(s) < 5:
		print(s)
	else:
		a = s.replace('party', 'pawri')
		print(a)


t = int(input())
while t != 0:
	t = t - 1
	s = input()
	x = 'pawri'
	y = 'party'
	if y in s:
		s = s.replace(y, x)
	print(s)


for i in range(int(input())):
	s = input()
	j = ''
	if 'party' in s:
		j = s.replace('party', 'pawri')
		print(j)
	else:
		print(s)


import re as g
for i in range(int(input())):
	s = input()
	p = list(g.sub('party', 'pawri', s))
	print(''.join(p))


n = int(input())
while n > 0:
	s = input()
	s = s.replace('party', 'pawri')
	print(s)
	n = n - 1


test = int(input())
word = 'party'
for i in range(test):
	string = input()
	if word in string:
		ans = string.replace('party', 'pawri')
		print(ans)
	else:
		print(string)


for i in range(int(input())):
	S = input()
	if 'party' in S:
		S = S.replace('party', 'pawri')
	print(S)


for i in range(int(input())):
	s = input()
	b = ''
	if 'party' not in s:
		print(s)
	else:
		l = s.split('party')
		for i in l:
			b += i + 'pawri'
		print(b[0:-5])


T = int(input())
for i in range(T):
	S = input()
	S1 = S.replace('party', 'pawri')
	print(S1)


import math
T = int(input())
for t in range(T):
	a = input()
	b = a.replace('party', 'pawri')
	print(b)


t = int(input())
for i in range(t):
	word = input()
	if 'party' in word:
		new = word.replace('party', 'pawri')
	else:
		new = word
	print(new)


T = int(input())
for i in range(T):
	s = input()
	x = s.replace('party', 'pawri')
	print(x)


for _ in range(int(input())):
	s = input()
	p = 'pawri'
	s = s.replace('party', 'pawri')
	print(s)


n = int(input())
while n != 0:
	x = input()
	k = x.count('party')
	if k >= 1:
		s = x.replace('party', 'pawri')
		print(s)
	else:
		print(x)
	n = n - 1


from itertools import permutations
for _ in range(int(input())):
	s = str(input())
	a = 'party'
	if a in s:
		x = s.replace(a, 'pawri')
		print(x)
	else:
		print(s)


t = int(input())
for test in range(0, t):
	string = input().casefold()
	print(string.replace('party', 'pawri'))


t = int(input())
for i in range(t):
	lst = list(map(str, input()))
	ans = ''
	j = 0
	while len(lst) - j > 0:
		if lst[j] == 'p' and len(lst) - j > 4:
			if lst[j + 1] == 'a':
				if lst[j + 2] == 'r':
					if lst[j + 3] == 't':
						if lst[j + 4] == 'y':
							ans += 'pawri'
							j += 5
						else:
							ans += 'part'
							j += 4
					else:
						ans += 'par'
						j += 3
				else:
					ans += 'pa'
					j += 2
			else:
				ans += 'p'
				j += 1
		else:
			ans += lst[j]
			j += 1
	print(ans)


n = int(input())
for i in range(0, n):
	m = input()
	k = m.count('party')
	if k >= 1:
		y = m.replace('party', 'pawri')
		print(y)
	else:
		print(m)


T = int(input())
A = []
for i in range(T):
	s = input()
	for j in range(len(s)):
		A.append(s[j])
	for j in range(len(A)):
		if A[j] == 'p' and j + 4 < len(A):
			if A[j] + A[j + 1] + A[j + 2] + A[j + 3] + A[j + 4] == 'party':
				A[j + 1] = 'a'
				A[j + 2] = 'w'
				A[j + 3] = 'r'
				A[j + 4] = 'i'
	for j in range(len(A)):
		print(A[j], end='')
	print()
	A = []


cases = int(input())
for _ in range(cases):
	s = input()
	word = 'party'
	if word in s:
		res = s.replace('party', 'pawri')
		print(res)
	else:
		print(s)


T = input()
t = int(T)
for x in range(t):
	S = input()
	t = S.replace('party', 'pawri')
	print(t)


t = int(input())
for i in range(0, t, 1):
	s = input()
	if 'party' in s:
		str = s.replace('party', 'pawri')
		print(str)
	else:
		print(s)


S = 'party'
T = int(input())
for i in range(T):
	s = input()
	if S in s:
		a = s.replace('party', 'pawri')
		print(a)
	else:
		print(s)


v = 'party'
for _ in range(int(input())):
	l = input()
	if v in l:
		r = l.replace('party', 'pawri')
		print(r)
	else:
		print(l)


t = int(input())
for i in range(0, t):
	s = str(input())
	x = s.replace('party', 'pawri')
	print(x)


t = int(input())
for tc in range(t):
	s = input()
	a = s.replace('party', 'pawri')
	if 'party' in s:
		print(a)
	else:
		print(s)


t = int(input())
for i in range(t):
	st = input()
	c = st.replace('party', 'pawri')
	print(c)


import re
for _ in range(int(input())):
	string = input()
	string = string.replace('party', 'pawri')
	print(string)


import re
for _ in range(int(input())):
	string = input()
	if 'party' in string:
		final = re.sub('party', 'pawri', string)
		print(final)
	else:
		print(string)