{"problem":{"name":"No Majority","description":{"content":"A string $x$ consisting of lowercase English letters is said to be **good** if and only if the following condition is satisfied. *   Every (contiguous) substring of $x$ whose length is $2$ or greater","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"agc060_a"},"statements":[{"statement_type":"Markdown","content":"A string $x$ consisting of lowercase English letters is said to be **good** if and only if the following condition is satisfied.\n\n*   Every (contiguous) substring of $x$ whose length is $2$ or greater satisfies the following:\n    *   no character occupies the majority of that substring.\n\nFor example, `acbca` is not good because `c` occupies the majority of the substring `cbc`.\nYou are given a string $S$ of length $N$ consisting of lowercase English letters and `?`. You want to replace each `?` with a lowercase English letter of your choice to make $S$ a good string. Find the number of ways to make $S$ a good string, modulo $998244353$.\n\n## Constraints\n\n*   $2 \\leq N \\leq 5000$\n*   $S$ is a string of length $N$ consisting of lowercase English letters and `?`.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$N$\n$S$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"agc060_a","tags":[],"sample_group":[["3\na?b","24\n\nEvery way other than `aab` and `abb` satisfies the condition."],["3\na?a","0"],["20\nugsyakganihodnwmktgi","1"],["20\n??a???h?m?y?ts???tl?","444225229"]],"created_at":"2026-03-03 11:01:14"}}