recently Polycarp notice button keyboard malfunction for simplicity assume Polycarps keyboard contain 26 button letter latin alphabet each button work fine malfunctioning to check button need replacement Polycarp press button sequence string s appear screen when Polycarp press button character c follow event happen button work correctly character c appear end stre Polycarp type button malfunction character c appear end string for example suppose button correspond character c work correctly button corresponding b malfunctioning if Polycarp press button order b c b string typing change follow rightarrow abb rightarrow abba rightarrow abbac rightarrow abbaca rightarrow abbacabb rightarrow abbacabbayou give string s appear screen Polycarp press button help Polycarp determine button work correctly sure string appear screen button malfunctioningyou assume button do not start malfunction Polycarp type stre button work correctly process malfunction process