{"raw_statement":[{"iden":"statement","content":"You all know that the Library of Bookland is the largest library in the world. There are dozens of thousands of books in the library.\n\n_Some long and uninteresting story was removed..._\n\nThe alphabet of Bookland is so large that its letters are denoted by positive integers. Each letter can be small or large, the large version of a letter _x_ is denoted by _x_'. BSCII encoding, which is used everywhere in Bookland, is made in that way so that large letters are presented in the order of the numbers they are denoted by, and small letters are presented in the order of the numbers they are denoted by, but all large letters are **before** all small letters. For example, the following conditions hold: 2 < 3, 2' < 3', 3' < 2.\n\nA word _x_1, _x_2, ..., _x__a_ is not _lexicographically_ greater than _y_1, _y_2, ..., _y__b_ if one of the two following conditions holds:\n\n*   _a_ ≤ _b_ and _x_1 = _y_1, ..., _x__a_ = _y__a_, i.e. the first word is the prefix of the second word;\n*   there is a position 1 ≤ _j_ ≤ _min_(_a_, _b_), such that _x_1 = _y_1, ..., _x__j_ - 1 = _y__j_ - 1 and _x__j_ < _y__j_, i.e. at the first position where the words differ the first word has a smaller letter than the second word has.\n\nFor example, the word \"3' 7 5\" is before the word \"2 4' 6\" in lexicographical order. It is said that sequence of words is in lexicographical order if each word is not lexicographically greater than the next word in the sequence.\n\nDenis has a sequence of words consisting of small letters only. He wants to change some letters to large (let's call this process a _capitalization_) in such a way that the sequence of words is in lexicographical order. However, he soon realized that for some reason he can't change a single letter in a single word. He only can choose a letter and change all of its occurrences in **all** words to large letters. He can perform this operation any number of times with arbitrary letters of Bookland's alphabet.\n\nHelp Denis to choose which letters he needs to capitalize (make large) in order to make the sequence of words lexicographically ordered, or determine that it is impossible.\n\nNote that some words can be **equal**."},{"iden":"input","content":"The first line contains two integers _n_ and _m_ (2 ≤ _n_ ≤ 100 000, 1 ≤ _m_ ≤ 100 000) — the number of words and the number of letters in Bookland's alphabet, respectively. The letters of Bookland's alphabet are denoted by integers from 1 to _m_.\n\nEach of the next _n_ lines contains a description of one word in format _l__i_, _s__i_, 1, _s__i_, 2, ..., _s__i_, _l__i_ (1 ≤ _l__i_ ≤ 100 000, 1 ≤ _s__i_, _j_ ≤ _m_), where _l__i_ is the length of the word, and _s__i_, _j_ is the sequence of letters in the word. The words are given in the order Denis has them in the sequence.\n\nIt is guaranteed that the total length of all words is not greater than 100 000."},{"iden":"output","content":"In the first line print \"_Yes_\" (without quotes), if it is possible to capitalize some set of letters in such a way that the sequence of words becomes lexicographically ordered. Otherwise, print \"_No_\" (without quotes).\n\nIf the required is possible, in the second line print _k_ — the number of letters Denis has to capitalize (make large), and in the third line print _k_ distinct integers — these letters. Note that you **don't need to minimize** the value _k_.\n\nYou can print the letters in any order. If there are multiple answers, print any of them."},{"iden":"examples","content":"Input\n\n4 3\n1 2\n1 1\n3 1 3 2\n2 1 1\n\nOutput\n\nYes\n2\n2 3 \n\nInput\n\n6 5\n2 1 2\n2 1 2\n3 1 2 3\n2 1 5\n2 4 4\n2 4 4\n\nOutput\n\nYes\n0\n\nInput\n\n4 3\n4 3 2 2 1\n3 1 1 3\n3 2 3 3\n2 3 1\n\nOutput\n\nNo"},{"iden":"note","content":"In the first example after Denis makes letters 2 and 3 large, the sequence looks like the following:\n\n*   2'\n*   1\n*   1 3' 2'\n*   1 1\n\nThe condition 2' < 1 holds, so the first word is not lexicographically larger than the second word. The second word is the prefix of the third word, so the are in lexicographical order. As the first letters of the third and the fourth words are the same, and 3' < 1, then the third word is not lexicographically larger than the fourth word.\n\nIn the second example the words are in lexicographical order from the beginning, so Denis can do nothing.\n\nIn the third example there is no set of letters such that if Denis capitalizes them, the sequence becomes lexicographically ordered."}],"translated_statement":[{"iden":"statement","content":"众所周知，Bookland 图书馆是世界上最大的图书馆，馆内有数以万计的书籍。\n\n_一段冗长且无趣的故事已被删除..._\n\nBookland 的字母表如此庞大，以至于其字母用正整数表示。每个字母都有小写和大写形式，字母 #cf_span[x] 的大写形式记为 #cf_span[x']。Bookland 中使用的 BSCII 编码规定：大写字母按其所表示的数字顺序排列，小写字母也按其所表示的数字顺序排列，但所有大写字母都位于所有小写字母之前。例如，以下条件成立：#cf_span[2 < 3]，#cf_span[2' < 3']，#cf_span[3' < 2]。\n\n单词 #cf_span[x1, x2, ..., xa] 在字典序上不大于单词 #cf_span[y1, y2, ..., yb]，当且仅当满足以下两个条件之一：\n\n例如，单词 \"#cf_span[3'] #cf_span[7] #cf_span[5]\" 在字典序上位于 \"#cf_span[2] #cf_span[4'] #cf_span[6]\" 之前。若序列中每个单词在字典序上都不大于其后一个单词，则称该单词序列是字典序有序的。\n\nDenis 有一个仅由小写字母组成的单词序列。他希望将某些字母改为大写（称此过程为 _大写化_），使得单词序列变为字典序有序。但他很快发现，出于某种原因，他不能单独更改某个单词中的单个字母。他只能选择一个字母，并将其在 *所有* 单词中的所有出现都改为大写字母。他可以对 Bookland 字母表中的任意字母执行此操作任意多次。\n\n请帮助 Denis 选择需要大写的字母集合，使得单词序列变为字典序有序，或判断这是不可能的。\n\n注意，某些单词可以是 *相等* 的。\n\n第一行包含两个整数 #cf_span[n] 和 #cf_span[m]（#cf_span[2 ≤ n ≤ 100 000]，#cf_span[1 ≤ m ≤ 100 000]）——单词的数量和 Bookland 字母表中字母的数量。Bookland 字母表中的字母用从 #cf_span[1] 到 #cf_span[m] 的整数表示。\n\n接下来的 #cf_span[n] 行每行描述一个单词，格式为 #cf_span[li, si, 1, si, 2, ..., si, li]（#cf_span[1 ≤ li ≤ 100 000]，#cf_span[1 ≤ si, j ≤ m]），其中 #cf_span[li] 是单词长度，#cf_span[si, j] 是单词中的字母序列。单词按 Denis 序列中的顺序给出。\n\n保证所有单词的总长度不超过 #cf_span[100 000]。\n\n如果存在某种方式选择一组字母进行大写化，使得单词序列变为字典序有序，则在第一行输出 \"_Yes_\"（不含引号）；否则输出 \"_No_\"（不含引号）。\n\n如果可行，则在第二行输出 #cf_span[k] —— Denis 需要大写的字母数量；在第三行输出 #cf_span[k] 个互不相同的整数 —— 这些字母。注意，你 *不需要最小化* #cf_span[k] 的值。\n\n你可以按任意顺序输出这些字母。如果有多个答案，输出任意一个即可。\n\n在第一个例子中，Denis 将字母 #cf_span[2] 和 #cf_span[3] 大写后，序列变为：\n\n条件 #cf_span[2' < 1] 成立，因此第一个单词在字典序上不大于第二个单词。第二个单词是第三个单词的前缀，因此它们是字典序有序的。由于第三个和第四个单词的首字母相同，且 #cf_span[3' < 1]，因此第三个单词在字典序上不大于第四个单词。\n\n在第二个例子中，单词序列从一开始就是字典序有序的，因此 Denis 无需做任何操作。\n\n在第三个例子中，不存在任何字母集合，使得 Denis 将其大写后序列变为字典序有序。"},{"iden":"input","content":"第一行包含两个整数 #cf_span[n] 和 #cf_span[m]（#cf_span[2 ≤ n ≤ 100 000]，#cf_span[1 ≤ m ≤ 100 000]）——单词的数量和 Bookland 字母表中字母的数量。Bookland 字母表中的字母用从 #cf_span[1] 到 #cf_span[m] 的整数表示。接下来的 #cf_span[n] 行每行描述一个单词，格式为 #cf_span[li, si, 1, si, 2, ..., si, li]（#cf_span[1 ≤ li ≤ 100 000]，#cf_span[1 ≤ si, j ≤ m]），其中 #cf_span[li] 是单词长度，#cf_span[si, j] 是单词中的字母序列。单词按 Denis 序列中的顺序给出。保证所有单词的总长度不超过 #cf_span[100 000]。"},{"iden":"output","content":"如果存在某种方式选择一组字母进行大写化，使得单词序列变为字典序有序，则在第一行输出 \"_Yes_\"（不含引号）；否则输出 \"_No_\"（不含引号）。如果可行，则在第二行输出 #cf_span[k] —— Denis 需要大写的字母数量；在第三行输出 #cf_span[k] 个互不相同的整数 —— 这些字母。注意，你 *不需要最小化* #cf_span[k] 的值。你可以按任意顺序输出这些字母。如果有多个答案，输出任意一个即可。"},{"iden":"examples","content":"输入\n4 3\n1 2\n1 1\n3 1 3 2\n2 1 1\n输出\nYes\n2\n2 3 \n\n输入\n6 5\n2 1 2\n2 1 2\n3 1 2 3\n2 1 5\n2 4 4\n2 4 4\n输出\nYes\n0\n\n输入\n4 3\n4 3 2 2 1\n3 1 1 3\n3 2 3 3\n2 3 1\n输出\nNo"},{"iden":"note","content":"在第一个例子中，Denis 将字母 #cf_span[2] 和 #cf_span[3] 大写后，序列变为： #cf_span[2'] #cf_span[1] #cf_span[1] #cf_span[3'] #cf_span[2'] #cf_span[1] #cf_span[1]。条件 #cf_span[2' < 1] 成立，因此第一个单词在字典序上不大于第二个单词。第二个单词是第三个单词的前缀，因此它们是字典序有序的。由于第三个和第四个单词的首字母相同，且 #cf_span[3' < 1]，因此第三个单词在字典序上不大于第四个单词。\n\n在第二个例子中，单词序列从一开始就是字典序有序的，因此 Denis 无需做任何操作。\n\n在第三个例子中，不存在任何字母集合，使得 Denis 将其大写后序列变为字典序有序。"}],"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ n, m \\in \\mathbb{Z}^+ $ denote the number of words and the number of letters (labeled $ 1 $ to $ m $), respectively.  \nLet $ W = (w_1, w_2, \\dots, w_n) $ be a sequence of words, where each word $ w_i = (s_{i,1}, s_{i,2}, \\dots, s_{i,\\ell_i}) $ is a sequence of letters $ s_{i,j} \\in \\{1, 2, \\dots, m\\} $.  \nLet $ C \\subseteq \\{1, 2, \\dots, m\\} $ be the set of letters to be capitalized (made large). For any letter $ x $, denote its large version by $ x' $.  \n\nThe BSCII ordering is defined as:  \n- For any $ x, y \\in \\{1, 2, \\dots, m\\} $:  \n  - $ x' < y' $ if and only if $ x < y $,  \n  - $ x < y $ if and only if $ x < y $,  \n  - $ x' < y $ for all $ x, y $.  \n\nA word $ u = (u_1, \\dots, u_p) $ is lexicographically $ \\leq $ word $ v = (v_1, \\dots, v_q) $ if:  \n- There exists an index $ k \\geq 1 $ such that $ u_i = v_i $ for all $ i < k $, and either $ k > p $ (i.e., $ u $ is a prefix of $ v $), or $ k \\leq \\min(p,q) $ and $ u_k < v_k $ under BSCII ordering.  \n\n**Constraints**  \n1. $ 2 \\leq n \\leq 100{,}000 $, $ 1 \\leq m \\leq 100{,}000 $  \n2. $ 1 \\leq \\ell_i \\leq 100{,}000 $ for all $ i \\in \\{1, \\dots, n\\} $  \n3. $ \\sum_{i=1}^n \\ell_i \\leq 100{,}000 $  \n4. All letters in input words are in $ \\{1, 2, \\dots, m\\} $  \n\n**Objective**  \nDetermine whether there exists a set $ C \\subseteq \\{1, 2, \\dots, m\\} $ such that, under BSCII ordering with large letters $ C' $, the sequence $ W $ is lexicographically non-decreasing:  \n$$\nw_1 \\leq w_2 \\leq \\dots \\leq w_n\n$$  \nIf such $ C $ exists, output \"Yes\", followed by $ |C| $ and any such $ C $. Otherwise, output \"No\".","simple_statement":null,"has_page_source":false}