#P1267D. DevOps Best Practices

    ID: 1979 Type: RemoteJudge 3000ms 512MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>constructive algorithms*2800

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 nn servers of your company. For every feature ff and every server ss, Daisy told you whether she wants the feature ff to be deployed on the server ss. If she wants it to be deployed, it must be done even if the feature ff fails the tests on the server ss. 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 s1s_1 to the server s2s_2 then every time s1s_1 receives a new feature ff the system starts the following deployment process of ff to s2s_2:

  • If the feature ff is already deployed on the server s2s_2, then nothing is done.
  • Otherwise, if CT is not set up on the server s1s_1, then the server s1s_1 just deploys the feature ff to the server s2s_2 without any testing.
  • Otherwise, the server s1s_1 runs tests for the feature ff. If the tests fail on the server s1s_1, nothing is done. If the tests pass, then the server s1s_1 deploys the feature ff to the server s2s_2.

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 264264 times.

The first line contains integer nn (2n2562 \le n \le 256) — the number of servers in your company.

Next nn lines contain three integers each. The jj-th integer in the ii-th line is 11 if Daisy wants the jj-th feature to be deployed to the ii-th server, or 00 otherwise.

Next nn lines contain three integers each. The jj-th integer in the ii-th line is 11 if tests pass for the jj-th feature on the ii-th server, or 00 otherwise.

Demid's development server has index 11. 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 264264 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 nn space-separated integers — the configuration of CT. The ii-th integer should be 11 if you set up CT on the ii-th server, or 00 otherwise.

Next line must contain the integer mm (0m2640 \le m \le 264) — the number of CD pairs you want to set up.

Each of the next mm lines must describe CD configuration, each line with two integers sis_i and tit_i (1si,tin1 \le s_i, t_i \le n; sitis_i \ne t_i), establishing automated deployment of new features from the server sis_i to the server tit_i.

Input

The first line contains integer nn (2n2562 \le n \le 256) — the number of servers in your company.

Next nn lines contain three integers each. The jj-th integer in the ii-th line is 11 if Daisy wants the jj-th feature to be deployed to the ii-th server, or 00 otherwise.

Next nn lines contain three integers each. The jj-th integer in the ii-th line is 11 if tests pass for the jj-th feature on the ii-th server, or 00 otherwise.

Demid's development server has index 11. 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 264264 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 nn space-separated integers — the configuration of CT. The ii-th integer should be 11 if you set up CT on the ii-th server, or 00 otherwise.

Next line must contain the integer mm (0m2640 \le m \le 264) — the number of CD pairs you want to set up.

Each of the next mm lines must describe CD configuration, each line with two integers sis_i and tit_i (1si,tin1 \le s_i, t_i \le n; sitis_i \ne t_i), establishing automated deployment of new features from the server sis_i to the server tit_i.

Samples

Sample Input 1

3
1 1 1
1 0 1
1 1 1
1 1 1
0 0 0
1 0 1

Sample Output 1

Possible
1 1 1
2
3 2
1 3

Sample Input 2

2
1 1 1
0 0 1
1 1 1
1 1 0

Sample Output 2

Impossible

Note

CD/CT system for the first sample test is shown below.