{"raw_statement":[{"iden":"statement","content":"You are given $n$ strings. Each string consists of lowercase English letters. Rearrange (reorder) the given strings in such a way that for every string, all strings that are placed before it are its _substrings_.\n\nString $a$ is a _substring_ of string $b$ if it is possible to choose several _consecutive_ letters in $b$ in such a way that they form $a$. For example, string \"_for_\" is contained as a _substring_ in strings \"_codeforces_\", \"_for_\" and \"_therefore_\", but is not contained as a _substring_ in strings \"_four_\", \"_fofo_\" and \"_rof_\"."},{"iden":"input","content":"The first line contains an integer $n$ ($1 \\le n \\le 100$) — the number of strings.\n\nThe next $n$ lines contain the given strings. The number of letters in each string is from $1$ to $100$, inclusive. Each string consists of lowercase English letters.\n\nSome strings might be equal."},{"iden":"output","content":"If it is impossible to reorder $n$ given strings in required order, print \"_NO_\" (without quotes).\n\nOtherwise print \"_YES_\" (without quotes) and $n$ given strings in required order."},{"iden":"examples","content":"Input\n\n5\na\naba\nabacaba\nba\naba\n\nOutput\n\nYES\na\nba\naba\naba\nabacaba\n\nInput\n\n5\na\nabacaba\nba\naba\nabab\n\nOutput\n\nNO\n\nInput\n\n3\nqwerty\nqwerty\nqwerty\n\nOutput\n\nYES\nqwerty\nqwerty\nqwerty"},{"iden":"note","content":"In the second example you cannot reorder the strings because the string \"_abab_\" is not a _substring_ of the string \"_abacaba_\"."}],"translated_statement":[{"iden":"statement","content":"你被给定 $n$ 个字符串。每个字符串由小写英文字母组成。请将这些字符串重新排列（排序），使得对于每一个字符串，所有排在它前面的字符串都是它的 _子串_。\n\n字符串 $a$ 是字符串 $b$ 的 _子串_，当且仅当可以在 $b$ 中选出若干个 _连续_ 的字母，使其恰好构成 $a$。例如，字符串 \"_for_\" 是字符串 \"_codeforces_\"、\"_for_\" 和 \"_therefore_\" 的 _子串_，但不是字符串 \"_four_\"、\"_fofo_\" 和 \"_rof_\" 的 _子串_。\n\n第一行包含一个整数 $n$ ($1 lt.eq n lt.eq 100$) —— 字符串的数量。\n\n接下来 $n$ 行包含给定的字符串。每个字符串的字母数量在 $1$ 到 $100$ 之间（含）。每个字符串均由小写英文字母组成。\n\n某些字符串可能相等。\n\n如果无法将给定的 $n$ 个字符串按要求重新排列，请输出 \"_NO_\"（不含引号）。\n\n否则，请输出 \"_YES_\"（不含引号），并在下一行按要求的顺序输出这 $n$ 个字符串。\n\n在第二个示例中，你无法重新排列字符串，因为字符串 \"_abab_\" 不是字符串 \"_abacaba_\" 的 _子串_。\n\n"},{"iden":"input","content":"第一行包含一个整数 $n$ ($1 lt.eq n lt.eq 100$) —— 字符串的数量。接下来 $n$ 行包含给定的字符串。每个字符串的字母数量在 $1$ 到 $100$ 之间（含）。每个字符串均由小写英文字母组成。某些字符串可能相等。"},{"iden":"output","content":"如果无法将给定的 $n$ 个字符串按要求重新排列，请输出 \"_NO_\"（不含引号）。否则，请输出 \"_YES_\"（不含引号），并在下一行按要求的顺序输出这 $n$ 个字符串。"},{"iden":"examples","content":"输入5aabaabacababaaba输出YESabaabaabaabacaba输入5aabacababaabaabab输出NO输入3qwertyqwertyqwerty输出YESqwertyqwertyqwerty"},{"iden":"note","content":"在第二个示例中，你无法重新排列字符串，因为字符串 \"_abab_\" 不是字符串 \"_abacaba_\" 的 _子串_。"}],"sample_group":[],"show_order":[],"formal_statement":"Let $ S = \\{s_1, s_2, \\dots, s_n\\} $ be a multiset of $ n $ strings over the alphabet $ \\Sigma = \\{a, b, \\dots, z\\} $.\n\n**Goal:** Determine if there exists a permutation $ \\sigma \\in S_n $ such that for all $ i \\in \\{2, 3, \\dots, n\\} $,  \n$$\ns_{\\sigma(i-1)} \\text{ is a substring of } s_{\\sigma(i)}.\n$$\n\nEquivalently, find an ordering $ t_1, t_2, \\dots, t_n $ of the strings in $ S $ such that:  \n$$\n\\forall i \\in \\{2, \\dots, n\\}, \\quad t_{i-1} \\sqsubseteq t_i,\n$$  \nwhere $ a \\sqsubseteq b $ denotes that string $ a $ is a contiguous substring of string $ b $.\n\n**Constraints:**\n- $ 1 \\leq n \\leq 100 $\n- Each string has length between 1 and 100, inclusive.\n- Strings may be duplicated.\n\n**Output:**\n- If such an ordering exists:  \n  Print \"YES\", followed by $ t_1, t_2, \\dots, t_n $.  \n- Otherwise:  \n  Print \"NO\".\n\n**Note:** The substring relation $ \\sqsubseteq $ is **not symmetric** and **not total**; it is reflexive and transitive. For the ordering to exist, the multiset must admit a total order under $ \\sqsubseteq $.","simple_statement":null,"has_page_source":false}