You are a Build Engineer working on recovered Atlantean data. You need to automate the product compilation to try and get this project done faster. Right now, they just have one project for their product but the number of source files is getting too large and they want to break it up into smaller projects. Each one of the smaller projects now can have a dependency on another project within the product. When a project is built, your build tool must first make sure the dependent projects are built first. If for some reason there is a circular dependency, you should print an error message saying that this build is not possible.
The input may contain several distinct products. Each product is self-contained, i.e. it will not depend on other products. The first line of input has the number N of products (1 ≤ N ≤ 100).
Each product will have on the first line P, the number of projects in the product (1 ≤ P ≤ 100).
On the second line will be B, the number of builds to run for this product (1 ≤ B ≤ 100).
The subsequent lines will have the project description, which is the number of dependent projects D (0 ≤ D ≤ 100) and the name of the project. The lines after that will have the names of the D projects it depends on.
After all of the projects and their dependencies are defined, there will be B build descriptions, which is the letter b and then the name of the Project to build. A project will never be defined to depend on itself.
For each product, output the order of each build as indicated in the sample output. Put a blank line between products. In the event that the order is irrelevant, sort by the name of the project.
3 4 2 1 ProjectA ProjectB 2 ProjectB ProjectD ProjectC 1 ProjectC ProjectD 0 ProjectD b ProjectA b ProjectC 2 1 1 ProjectA ProjectB 1 ProjectB ProjectA b ProjectA 3 1 2 ProjectA ProjectC ProjectB 0 ProjectC 0 ProjectB b ProjectA
Product 1: Build 1: ProjectD ProjectC ProjectB ProjectA Build 2: ProjectD ProjectC Product 2: Build 1: This build is not possible. Product 3: Build 1: ProjectC ProjectB ProjectA