using System.Diagnostics; class Program { static string ReadLine() => Console.ReadLine().Trim(); static int ReadInt() => int.Parse(ReadLine()); static long ReadLong() => long.Parse(ReadLine()); static int[] ReadIntArray() { string str = ReadLine(); return str != "" ? str.Split().Select(_ => int.Parse(_)).ToArray() : new int[0]; } static long[] ReadLongArray() { string str = ReadLine(); return str != "" ? str.Split().Select(_ => long.Parse(_)).ToArray() : new long[0]; } static (int, int) ReadInt2() { int[] vs = ReadIntArray(); return (vs[0], vs[1]); } static (int, int, int) ReadInt3() { int[] vs = ReadIntArray(); return (vs[0], vs[1], vs[2]); } static (int, int, int, int) ReadInt4() { int[] vs = ReadIntArray(); return (vs[0], vs[1], vs[2], vs[3]); } static (int, int, int, int, int) ReadInt5() { int[] vs = ReadIntArray(); return (vs[0], vs[1], vs[2], vs[3], vs[4]); } static (long, long) ReadLong2() { long[] vs = ReadLongArray(); return (vs[0], vs[1]); } static (long, long, long) ReadLong3() { long[] vs = ReadLongArray(); return (vs[0], vs[1], vs[2]); } static void Main() { SourceExpander.Expander.Expand(); int T = ReadInt(); for (int i = 0; i < T; i++) { string R = ReadLine(); string S = ReadLine(); int K = ReadInt(); if (S == "NotWarong") { Console.WriteLine(R); } else { char[] s = R.ToArray(); for (int j = 0; j < K; j++) { if (s[j] == '?') s[j] = 'A'; } int q_cnt = 0; int w_cnt = 0; for (int j = K; j < s.Length; j++) { if (s[j] == '?') q_cnt++; if (s[j] == 'W') w_cnt++; } if (w_cnt == 0 && q_cnt == 1) { for (int j = K; j < s.Length; j++) { if (s[j] == '?') s[j] = 'W'; } } Console.WriteLine(new string(s)); } } } void F11() { (int N, int K) = ReadInt2(); long[] A = ReadLongArray(); long[] dp = new long[K + 1]; for (int i = 0; i < N; i++) { long v = A[i]; long[] n_dp = (long[])dp.Clone(); for (int j = 0; j <= K; j++) { if (j + 1 <= K && n_dp[j + 1] < dp[j] + v) n_dp[j + 1] = dp[j] + v; if (n_dp[j] < dp[j]) n_dp[j] = dp[j]; } dp = n_dp; } //Console.WriteLine(dp.Max()); } } #region Expanded by https://github.com/kzrnm/SourceExpander namespace SourceExpander{public class Expander{[Conditional("EXP")]public static void Expand(string inputFilePath=null,string outputFilePath=null,bool ignoreAnyError=true){}public static string ExpandString(string inputFilePath=null,bool ignoreAnyError=true){return "";}}} #endregion Expanded by https://github.com/kzrnm/SourceExpander