{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"Order is an important concept in mathematics and in computer science. For example, Zorn\u0027s Lemma states: ``a partially ordered set in which every chain has an upper bound contains a maximal element.\u0027\u0027 Order is also important in reasoning about the fix-point semantics of programs. \u003cbr\u003e\u003cbr\u003e\u003cbr\u003eThis problem involves neither Zorn\u0027s Lemma nor fix-point semantics, but does involve order. \u003cbr\u003eGiven a list of variable constraints of the form x \u0026lt; y, you are to write a program that prints all orderings of the variables that are consistent with the constraints. \u003cbr\u003e\u003cbr\u003e\u003cbr\u003eFor example, given the constraints x \u0026lt; y and x \u0026lt; z there are two orderings of the variables x, y, and z that are consistent with these constraints: x y z and x z y. \u003cbr\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The input consists of a sequence of constraint specifications. A specification consists of two lines: a list of variables on one line followed by a list of contraints on the next line. A constraint is given by a pair of variables, where x y indicates that x \u0026lt; y. \u003cbr\u003e\u003cbr\u003e\u003cbr\u003eAll variables are single character, lower-case letters. There will be at least two variables, and no more than 20 variables in a specification. There will be at least one constraint, and no more than 50 constraints in a specification. There will be at least one, and no more than 300 orderings consistent with the contraints in a specification. \u003cbr\u003e\u003cbr\u003e\u003cbr\u003eInput is terminated by end-of-file. \u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"For each constraint specification, all orderings consistent with the constraints should be printed. Orderings are printed in lexicographical (alphabetical) order, one per line. \u003cbr\u003e\u003cbr\u003e\u003cbr\u003eOutput for different constraint specifications is separated by a blank line. \u003cbr\u003e"}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003ea b f g\r\na b b f\r\nv w x y z\r\nv y x v z v w v\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eabfg\r\nabgf\r\nagbf\r\ngabf\r\n\r\nwxzvy\r\nwzxvy\r\nxwzvy\r\nxzwvy\r\nzwxvy\r\nzxwvy\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}