using System; using System.Collections.Generic; using System.Linq; class Program { static string InputPattern = "InputX"; static List GetInputList() { var WillReturn = new List(); if (InputPattern == "Input1") { WillReturn.Add("2 8"); WillReturn.Add("..yiwiy9"); WillReturn.Add("9yiwiy.."); //..yiwiY9 //9Yiwiy.. } else { string wkStr; while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr); } return WillReturn; } static long[] GetSplitArr(string pStr) { return (pStr == "" ? new string[0] : pStr.Split(' ')).Select(pX => long.Parse(pX)).ToArray(); } static void Main() { List InputList = GetInputList(); foreach (string EachStr in InputList.Skip(1)) { int CurrInd = 0; int UB = EachStr.Length - 1; var sb = new System.Text.StringBuilder(); while (CurrInd <= UB) { int RangeSta = CurrInd; if (RangeSta + 5 <= UB) { string SubStr = EachStr.Substring(CurrInd, 6); if (SubStr == "9yiwiy") { sb.Append("9Yiwiy"); CurrInd += 6; continue; } else if (SubStr == "yiwiy9") { sb.Append("yiwiY9"); CurrInd += 6; continue; } } sb.Append(EachStr[CurrInd]); CurrInd++; } Console.WriteLine(sb.ToString()); } } }