#P1267D. DevOps Best Practices
DevOps Best Practices
No submission language available for this problem.
Description
Daisy is a senior software engineer at RainyDay, LLC. She has just implemented three new features in their product: the first feature makes their product work, the second one makes their product fast, and the third one makes their product correct. The company encourages at least some testing of new features, so Daisy appointed her intern Demid to write some tests for the new features.
Interestingly enough, these three features pass all the tests on Demid's development server, which has index 1, but might fail the tests on some other servers.
After Demid has completed this task, Daisy appointed you to deploy these three features to all servers of your company. For every feature and every server , Daisy told you whether she wants the feature to be deployed on the server . If she wants it to be deployed, it must be done even if the feature fails the tests on the server . If she does not want it to be deployed, you may not deploy it there.
Your company has two important instruments for the deployment of new features to servers: Continuous Deployment (CD) and Continuous Testing (CT). CD can be established between several pairs of servers, forming a directed graph. CT can be set up on some set of servers.
If CD is configured from the server to the server then every time receives a new feature the system starts the following deployment process of to :
- If the feature is already deployed on the server , then nothing is done.
- Otherwise, if CT is not set up on the server , then the server just deploys the feature to the server without any testing.
- Otherwise, the server runs tests for the feature . If the tests fail on the server , nothing is done. If the tests pass, then the server deploys the feature to the server .
You are to configure the CD/CT system, and after that Demid will deploy all three features on his development server. Your CD/CT system must deploy each feature exactly to the set of servers that Daisy wants.
Your company does not have a lot of computing resources, so you can establish CD from one server to another at most times.
The first line contains integer () — the number of servers in your company.
Next lines contain three integers each. The -th integer in the -th line is if Daisy wants the -th feature to be deployed to the -th server, or otherwise.
Next lines contain three integers each. The -th integer in the -th line is if tests pass for the -th feature on the -th server, or otherwise.
Demid's development server has index . It is guaranteed that Daisy wants all three features to be deployed to the server number 1, and all three features pass their tests on the server number 1.
If it is impossible to configure CD/CT system with CD being set up between at most pairs of servers, then output the single line "Impossible".
Otherwise, the first line of the output must contain the line "Possible".
Next line must contain space-separated integers — the configuration of CT. The -th integer should be if you set up CT on the -th server, or otherwise.
Next line must contain the integer () — the number of CD pairs you want to set up.
Each of the next lines must describe CD configuration, each line with two integers and (; ), establishing automated deployment of new features from the server to the server .
Input
The first line contains integer () — the number of servers in your company.
Next lines contain three integers each. The -th integer in the -th line is if Daisy wants the -th feature to be deployed to the -th server, or otherwise.
Next lines contain three integers each. The -th integer in the -th line is if tests pass for the -th feature on the -th server, or otherwise.
Demid's development server has index . It is guaranteed that Daisy wants all three features to be deployed to the server number 1, and all three features pass their tests on the server number 1.
Output
If it is impossible to configure CD/CT system with CD being set up between at most pairs of servers, then output the single line "Impossible".
Otherwise, the first line of the output must contain the line "Possible".
Next line must contain space-separated integers — the configuration of CT. The -th integer should be if you set up CT on the -th server, or otherwise.
Next line must contain the integer () — the number of CD pairs you want to set up.
Each of the next lines must describe CD configuration, each line with two integers and (; ), establishing automated deployment of new features from the server to the server .
Samples
Note
CD/CT system for the first sample test is shown below.
