{"raw_statement":[{"iden":"background","content":"Farmer John is interested in better interacting with his fellow cows, so he\ndecided he will learn the moo language!"},{"iden":"statement","content":"Moo language is actually quite similar to English, but more minimalistic. There\nare only four types of words: nouns, transitive verbs, intransitive verbs, and\nconjunctions. Every two consecutive words must be separated by a space.  There\nare also only two types of punctuation: periods and commas.  When a period or\ncomma appears after a word, it appears directly after the word, and is then\nfollowed  by a space if another word appears next.\n\nA sentence needs to follow one of the following formats:\n- Type 1: noun + intransitive verb.\n- Type 2: noun + transitive verb + noun(s). Specifically, at least one noun\nmust follow the transitive verb, and there must be a comma in front of every \nfollowing noun besides the first following noun.\n\nTwo sentences may be joined into a compound sentence if a conjunction is placed\nin between them.  The resulting compound sentence cannot be further joined with\nother sentences or other compound sentences.  Every sentence (or compound\nsentence, if two sentences are joined) must end with a period.\n\nFarmer John has a word bank of $N$ words, $C$ commas, and $P$ periods. He may only use a word or punctuation mark as\nmany times as it appears in the word bank. Help him output a sequence of\nsentences containing the maximum possible number of words.\n\nEach input file contains $T$ independent instances of this\nproblem.\n"},{"iden":"input","content":"The first line contains $T$, the number of instances. Each instance is specified\nas follows:\n\nThe first line consists of three integers $N, C$ and $P$.\n\nThe $N$ following lines will consist of two strings. The first string will be\nthe word itself that FJ can use (a string of at least $1$ and at most $10$ lowercase\nletters), and the second string will be either one of the following: noun,\ntransitive-verb, intransitive-verb, or conjunction, denoting the type of the\nword. It is possible the same word occurs more than once in FJ's word bank, but\nit will always have the same type each time it appears."},{"iden":"output","content":"In the first line, output the maximum possible number of words.\n\nIn the second line, output any sequence of sentences with the maximum possible\nnumber of words. Any valid sequence will be accepted.\n\n**The grader is sensitive to whitespace, so make sure not to output any\nextraneous spaces, particularly at the end of each line.**"},{"iden":"note","content":"$1\\le T\\le 100$，$1 \\leq P,C\\le N \\leq 10^3$.\n\n- Inputs 2-6: $N\\le 10$.\n- Inputs 7-11: $N\\le 100$.\n- Inputs 12-16: $N\\le 1000$.\n- Inputs with remainder 2 when divided by 5: There are no transitive\nverbs.\n- Inputs with remainder 3 when divided by 5: There are no intransitive\nverbs.\n- Inputs with remainder 4 when divided by 5: There are no conjunctions."}],"translated_statement":null,"sample_group":[["3\n1 1 1\nbessie noun\n10 5 4\nbessie noun\ntaught transitive-verb\nflew intransitive-verb\nelsie noun\nfarmer noun\njohn noun\nand conjunction\nand conjunction\nnhoj noun\nmooed intransitive-verb\n24 5 4\nbut conjunction\nbessie noun\ntaught transitive-verb\nflew intransitive-verb\nelsie noun\nfarmer noun\njohn noun\nand conjunction\nand conjunction\nnhoj noun\nmooed intransitive-verb\nbob noun\nimpressed transitive-verb\ncow noun\nimpressed transitive-verb\nleaped intransitive-verb\nelsie noun\nbella noun\nbuttercup noun\npushed transitive-verb\nmooed intransitive-verb\nenvy noun\njohn noun\nnhoj noun\n","0\n\n9\nnhoj mooed. farmer taught elsie, bessie and john flew.\n23\nnhoj mooed. nhoj impressed john, farmer, elsie, bessie and cow impressed bob. bella pushed elsie and buttercup flew. envy mooed but john leaped."]],"show_order":[],"formal_statement":null,"simple_statement":null,"has_page_source":false}