x,z,s,t;main(i){for(;read(0,&z,1);)z&1?x=z,z%3?s--,~t&&t++:~s&&s++:z&8?s=t=--i&&!puts("impossible"+2*!(t|s<0|x-71)):t--;}