var N=30,S=15,T=S-1,P='DDD0D0D00000',u,w=[];p=[];R=(k,x,y,l,h)=>{c.fillStyle='#'+P.substr(k*3,3);c.fillRect(x,y+S,l,h)};
D=(x)=>{var i=x[5],j=x[6];R(x[4],i*S,j*S,S,S);if(x[0])R(3,i*S,j*S,S,1);if(x[1])R(3,i*S+T,j*S,1,S);if(x[2])R(3,i*S,j*S+T,S,1);if(x[3])R(3,i*S,j*S,1,S)}
C=(x)=>{u=x;u[4]=2;D(u)};M=(x)=>{u[4]=1;D(u);C(x)};V=(i,j)=>{return(i>=0&&i<N&&j>=0&&j<N&&w[i*N+j][4]==0)?w[i*N+j]:null};
B=()=>{var i=u[5],j=u[6],f=[],x;x=V(i-1,j);if(x)f.push(x);x=V(i+1,j);if(x)f.push(x);x=V(i,j-1);if(x)f.push(x);x=V(i,j+1);if(x)f.push(x);return f};
F=(x)=>{if(x[6]==u[6]){if(x[5]<u[5]){x[1]=u[3]=0}else{x[3]=u[1]=0}}else{if(x[6]>u[6]){x[0]=u[2]=0}else{x[2]=u[0]=0}}};
X=()=>{var d=0,x,l=B();if(l.length){x=l[Math.floor(Math.random()*l.length)];F(x);M(x);p.push(x)}else if(p.length)M(p.pop()); else d=1;return d};
for(i=0;i<N;i++)for(j=0;j<N;j++){w[i*N+j]=[1,1,1,1,0,i,j];D(w[i*N+j])};p.push(w[0]);C(w[0]);I=setInterval(function(){if(X())clearInterval(I)},20);
dmFyIE49MzAsUz0xNSxUPVMtMSxQPSdEREQwRDBEMDAwMDAnLHUsdz1bXTtwPVtdO1I9KGsseCx5LGwsaCk9PntjLmZpbGxTdHlsZT0nIycrUC5zdWJzdHIoayozLDMpO2MuZmlsbFJlY3QoeCx5K1MsbCxoKX07DQpEPSh4KT0+e3ZhciBpPXhbNV0saj14WzZdO1IoeFs0XSxpKlMsaipTLFMsUyk7aWYoeFswXSlSKDMsaSpTLGoqUyxTLDEpO2lmKHhbMV0pUigzLGkqUytULGoqUywxLFMpO2lmKHhbMl0pUigzL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