Upd:已填坑
//代码未经完全精简和注释,主要是太困咕了,有时间提醒我的话说不定会回来补。/kun/kun/kun
#include<iostream>
#include<iomanip>
#include<cmath>
#include<ctime>
#include<cctype>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<climits>
//#define NDEBUG
#include<cassert>
#include<complex>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<bitset>
//#define LL __int128
#define LL long long
#define ULL unsigned LL
#define uint unsigned int
//#define int LL
//#define double long double
#define par pair<int,int>
#define mkp make_pair
#define epb emplace_back
#define psb push_back
#define f(x) ((x).first)
#define s(x) ((x).second)
using namespace std;
#define Lbt(x) ((x)&(-(x)))
#define Swap(x,y) (x^=y^=x^=y)
const int Mxxx=1e5;
inline char gc()
{
static char buf[Mxxx],*p1=buf,*p2=buf;
return p1==p2&&(p2=(p1=buf)+fread(buf,1,Mxxx,stdin),p1==p2)?EOF:*p1++;
}
inline char pc(char ch,bool fl=false)
{
static char buf[Mxxx],*p1=buf,*p2=buf+Mxxx;
return (fl||((*p1++=ch)&&p1==p2))&&(fwrite(buf,1,p1-buf,stdout),p1=buf),0;
}
//#define gc getchar
//#define pc(x,y) y?0:putchar(x)
#define output pc('!',true)
inline int read()
{
char ch=gc();
int gflag=0,gans=0;
while(ch<'0'||ch>'9')
{
gflag|=(ch=='-');
ch=gc();
}
while('0'<=ch&&ch<='9')
{
gans=(gans<<1)+(gans<<3)+(ch^48);
ch=gc();
}
return gflag?-gans:gans;
}
template<typename T>
inline char read(T &gans)
{
char ch=gc();
int gflag=0;
gans=0;
while(ch<'0'||ch>'9')
{
gflag|=(ch=='-');
ch=gc();
}
while('0'<=ch&&ch<='9')
{
gans=(gans<<1)+(gans<<3)+(ch^48);
ch=gc();
}
gans=gflag?-gans:gans;
return ch;
}
template<typename T>
inline void write(T x)
{
if(x>9)
{
write(x/10);
}
pc(x%10^48);
}
template<typename T>
inline void writenum(T x,char ch)
{
if(x<0)
{
pc('-');
x=-x;
}
write(x);
pc(ch);
}
inline void writechar(char x,char ch)
{
pc(x);
pc(ch);
}
template<typename T>
inline T Min(T x,T y)
{
return x<y?x:y;
}
template<typename T>
inline T Max(T x,T y)
{
return x>y?x:y;
}
template<typename T>
inline T Abs(T x)
{
return x>0?x:-x;
}
template<typename T>
inline void ckmx(T &x,T y)
{
x=Max(x,y);
}
template<typename T>
inline void ckmn(T &x,T y)
{
x=Min(x,y);
}
const int Mx=1<<8;
vector<par>pre[2][8];
inline void Pre(int x)
{
int i;
pre[0][0].epb(mkp(1,1));
pre[0][0].epb(mkp(0,1));
pre[0][0].epb(mkp(0,0));
pre[0][0].epb(mkp(1,0));
for(par to:pre[0][0])pre[1][0].epb(to);
reverse(pre[1][0].begin(),pre[1][0].end());
for(i=1;i<x;i++)
{
pre[0][i].epb(mkp(i+1,1));
for(par to:pre[0][i-1])
{
pre[0][i].epb(to);
}
pre[0][i].epb(mkp(i,1));
pre[0][i].epb(i+1,1);
pre[0][i].epb(i+1,0);
for(par to:pre[1][i-1])
{
pre[0][i].epb(mkp(f(to),s(to)));
}
pre[0][i].epb(mkp(i,0));
pre[0][i].epb(mkp(i+1,0));
for(par to:pre[0][i])pre[1][i].epb(to);
reverse(pre[1][i].begin(),pre[1][i].end());
}
}
int tot;
const int M=250000;
par ans[M+5];
inline void Prt(int x,int y,int z)
{
if(x==y)return;
int i;
if(x<y)
{
x++;
// cout<<"Prt:"<<x<<" "<<y<<" "<<z<<"\n";
if(!z)ans[++tot]=mkp(x,1);
for(i=x+1;i<=y;i++)
{
assert(tot<=M);
ans[++tot]=mkp(i,1);
}
if(!z)ans[++tot]=mkp(y,0);
}
if(x>y)
{
y++;
// cout<<"Prt:"<<x<<" "<<y<<" "<<z<<"\n";
if(!z)ans[++tot]=mkp(x,0);
for(i=x;i>y;i--)
{
assert(tot<=M);
ans[++tot]=mkp(i,1);
}
if(!z)ans[++tot]=mkp(y,1);
}
}
inline void l_r(int x,int y)
{
int i;
for(i=x;i<=y;i++)
{
ans[++tot]=mkp(i,1);
}
}
inline void r_l(int x,int y)
{
int i;
for(i=x;i>=y;i--)
{
ans[++tot]=mkp(i,1);
}
}
int n;
vector<int>vec;
inline void Slv(int x)
{
assert(x);
int i,k,t=0,fst=0,scd=0;
for(i=n-1;~i;i--)
{
if((x>>i)&1)
{
t++;vec.epb(i);
}
}
vec.epb(vec.back()-1);
// cout<<"Slv:"<<x<<":"<<t<<"|"<<vec.back()<<"\n";
l_r(0,vec.back());
// cout<<"Slv_ck:"<<f(ans[tot])<<" "<<s(ans[tot])<<"\n";
for(i=0,k=pre[0][--t].size();i<k;i++)
{
fst=f(pre[0][t][i]);scd=s(pre[0][t][i]);
// cout<<"Slv_pro:"<<i<<":"<<fst<<" "<<scd<<"\n";
if(i&&fst^f(pre[0][t][i-1])&&Abs(vec[fst]-vec[f(pre[0][t][i-1])])>1)
{
assert(scd==s(pre[0][t][i-1]));
Prt(vec[f(pre[0][t][i-1])],vec[fst],scd);
}
assert(tot<=M);
ans[++tot]=mkp(vec[fst]+1,scd);
}
// cout<<"Slv_end:"<<fst<<" "<<scd<<":"<<vec[fst]<<"|"<<f(ans[tot])<<" "<<s(ans[tot])<<"\n";
r_l(vec[fst]+1,1);
vec.clear();
}
int top,a[Mx+5],stk[Mx+5];
inline int gt()
{
char ch;
for(ch=gc();ch^48&&ch^49;ch=gc());
// cout<<ch<<":"<<((int)ch)<<"\n";
return ch==49;
}
signed main()
{
#ifndef ONLINE_JUDGE
freopen("_.in","r",stdin);
// freopen("_.out","w",stdout);
#endif
int i,j,k,f;
n=read();
for(i=0;i<1<<n;i++)
{
for(f=!(a[i]=gt()),j=0;j<n;j++)
{
if(i&(1<<j))
{
k=i^(1<<j);
if(a[i]&&!a[k])
{
puts("Impossible");
return output;
}
f&=a[k];
}
}
// cout<<"a:"<<i<<":"<<a[i]<<"|"<<f<<"\n";
if(f)
{
// cout<<"chked_a:"<<i<<":"<<a[i]<<"|"<<f<<"\n";
stk[++top]=i;
}
}
puts("Possible");
Pre(n);
for(;top;Slv(stk[top--]))
// if(top<2)break
;
writenum(tot,10);
assert(tot<=M);
ans[++tot]=mkp(0,1);
for(i=1;i<=tot;i++)
{
writenum(f(ans[i]),32);writenum(s(ans[i]),10);
}
return output;
}
/*
1
10
*/
/*
2
1000
*/
/*
2
1001
*/
/*
1
11
*/
/*
2
1100
*/
/*
2
1110
*/
/*
3
10000000
*/
/*
3
11110000
*/
/*
3
11111000
*/
/*
3
11001000
*/
/*
3
11111110
*/