#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <functional>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
#include <tuple>
using namespace std;
typedef long long LL;
typedef complex<double> CMP;

class Family { public:
	string isFamily(vector <int> parent1, vector <int> parent2)
	{
		return solve(parent1, parent2) ? "Possible" : "Impossible";
	}

	bool solve(vector <int> parent1, vector <int> parent2)
	{
		const int N = parent1.size();

		map<int, vector<int>> diff;
		for(int i=0; i<N; ++i)
		{
			int a = parent1[i];
			int b = parent2[i];
			if(a != -1) {
				assert(b != -1);
				diff[a].push_back(b);
				diff[b].push_back(a);
			}
		}

		bool ok = true;

		enum {Unk, Ma=1, Fe=2};
		vector<int> gender(N, Unk);
		function<void(int)> rec_fill; rec_fill = [&](int p) {
			for(int q : diff[p])
				if(gender[q] == Unk) {
					gender[q] = 3 - gender[p];
					rec_fill(q);
				} else if(gender[q] == gender[p]) {
					ok = false;
					return;
				}
		};

		for(int p=0; p<N; ++p)
		{
			if(gender[p] == Unk) {
				gender[p] = Ma;
				rec_fill(p);
				if(!ok)
					return ok;
			}
		}
		return ok;
	}
};

// BEGIN CUT HERE
#include <ctime>
double start_time; string timer()
 { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
 { os << "{ ";
   for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
   os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; }
void verify_case(const string& Expected, const string& Received) {
 bool ok = (Expected == Received);
 if(ok) cerr << "PASSED" << timer() << endl;  else { cerr << "FAILED" << timer() << endl;
 cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } }
#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock();
#define END	 verify_case(_, Family().isFamily(parent1, parent2));}
int main(){

CASE(0)
	int parent1_[] = {-1,-1,0};
	  vector <int> parent1(parent1_, parent1_+sizeof(parent1_)/sizeof(*parent1_)); 
	int parent2_[] = {-1,-1,1};
	  vector <int> parent2(parent2_, parent2_+sizeof(parent2_)/sizeof(*parent2_)); 
	string _ = "Possible"; 
END
CASE(1)
	int parent1_[] = {-1,-1,-1,-1,-1};
	  vector <int> parent1(parent1_, parent1_+sizeof(parent1_)/sizeof(*parent1_)); 
	int parent2_[] = {-1,-1,-1,-1,-1};
	  vector <int> parent2(parent2_, parent2_+sizeof(parent2_)/sizeof(*parent2_)); 
	string _ = "Possible"; 
END
CASE(2)
	int parent1_[] = {-1,-1,0,0,1};
	  vector <int> parent1(parent1_, parent1_+sizeof(parent1_)/sizeof(*parent1_)); 
	int parent2_[] = {-1,-1,1,2,2};
	  vector <int> parent2(parent2_, parent2_+sizeof(parent2_)/sizeof(*parent2_)); 
	string _ = "Impossible"; 
END
CASE(3)
	int parent1_[] = {-1,-1,-1,-1,1,-1,0,5,6,-1,0,3,8,6}
;
	  vector <int> parent1(parent1_, parent1_+sizeof(parent1_)/sizeof(*parent1_)); 
	int parent2_[] = {-1,-1,-1,-1,3,-1,4,6,5,-1,5,4,6,1}
;
	  vector <int> parent2(parent2_, parent2_+sizeof(parent2_)/sizeof(*parent2_)); 
	string _ = "Possible"; 
END
CASE(4)
	int parent1_[] = {-1,-1,-1,2,2,-1,5,6,4,6,2,1,8,0,2,4,6,9,-1,16,-1,11};
	  vector <int> parent1(parent1_, parent1_+sizeof(parent1_)/sizeof(*parent1_)); 
	int parent2_[] = {-1,-1,-1,1,0,-1,1,4,2,0,4,8,2,3,0,5,14,14,-1,7,-1,13};
	  vector <int> parent2(parent2_, parent2_+sizeof(parent2_)/sizeof(*parent2_)); 
	string _ = "Impossible"; 
END
/*
CASE(5)
	int parent1_[] = ;
	  vector <int> parent1(parent1_, parent1_+sizeof(parent1_)/sizeof(*parent1_)); 
	int parent2_[] = ;
	  vector <int> parent2(parent2_, parent2_+sizeof(parent2_)/sizeof(*parent2_)); 
	string _ = ; 
END
CASE(6)
	int parent1_[] = ;
	  vector <int> parent1(parent1_, parent1_+sizeof(parent1_)/sizeof(*parent1_)); 
	int parent2_[] = ;
	  vector <int> parent2(parent2_, parent2_+sizeof(parent2_)/sizeof(*parent2_)); 
	string _ = ; 
END
*/
}
// END CUT HERE
