a;main(s){for(;a||~scanf("%d",&s);a%=4)printf(a++/3*8+"%d %d %d\n",a-2?s>2+3*a:s-1&&s-3,s&1&a,a?s>8-3*a:s-1&&s-3);}