import sys, time, random, heapq, math, itertools, copy from collections import deque, Counter, defaultdict #from sortedcontainers import SortedSet, SortedList from bisect import bisect, bisect_left, bisect_right import heapq as hq from functools import cache, cmp_to_key def debug(*x):print('debug:',*x, file=sys.stderr) sys.setrecursionlimit(300000) input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) inf = 2 ** 61 - 1 mod = 998244353 dir = [(0, 1), (0, -1), (1, 0), (-1, 0)] T = ii() for _ in range(T): R = list(input()) S = input() K = ii() if S == "Warong": # 最初K文字はAで確定する for i in range(K): R[i] = "A" # 残りについて,Wがないかつ?が一つならそこはW確定 cnt_W = False cnt_hatena = 0 for i in range(len(R)): if R[i] == "?": cnt_hatena += 1 if R[i] == "W": cnt_W += 1 if cnt_W == 0 and cnt_hatena == 1: for i in range(len(R)): if R[i] == "?": R[i] = "W" break print("".join(R))