import Data.List
import Data.Function
baytiki = sobratBaytiki bitiki
skleitBaytik bitiki = f 0 [] bitiki where
f n baytik w@(~((c@(~(b:bs))):bitiki))
| n==8 = [(baytik,w)]
| null c
= f n baytik bitiki
da
= f
(n
+length b
) (b:baytik
) (bs:bitiki
) ne
= map (fmap (c:
)) (f n baytik bitiki
)
sobratBaytiki bitiki =
[([],podgotovit bitiki)]
aW1wb3J0IERhdGEuTGlzdAppbXBvcnQgRGF0YS5GdW5jdGlvbgoKbWFpbiA9IGdldENvbnRlbnRzID4+PSBcdnZvZCAtPiBsZXQKCWJpdGlraSA9IGZpbHRlciAoYWxsIChgZWxlbWAgIjAxIikpICQgd29yZHMgdnZvZCAKCWJheXRpa2kgPSBzb2JyYXRCYXl0aWtpIGJpdGlraQoJaW4gbWFwTV8gKHB1dFN0ckxuIC4gaW50ZXJjYWxhdGUgIiArICIpIGJheXRpa2kKCnNrbGVpdEJheXRpayBiaXRpa2kgPSBmIDAgW10gYml0aWtpIHdoZXJlCiAgICBmIG4gYmF5dGlrIHdAKH4oKGNAKH4oYjpicykpKTpiaXRpa2kpKSAKICAgICAgICB8IG49PTggICAgICAgICAgID0gWyhiYXl0aWssdyldCiAgICAgICAgfCA4PG4gfHwgbnVsbCB3ICA9IFtdCiAgICAgICAgfCBudWxsIGMgPSBmIG4gYmF5dGlrIGJpdGlraQogICAgICAgIHwgb3RoZXJ3aXNlICAgICAgPSB0YWtlIDEgKGRhICsrIG5lKSB3aGVyZSAKICAgICAgICAgICAgZGEgPSBmIChuK2xlbmd0aCBiKSAoYjpiYXl0aWspIChiczpiaXRpa2kpCiAgICAgICAgICAgIG5lID0gbWFwIChmbWFwIChjOikpIChmIG4gYmF5dGlrIGJpdGlraSkKICAgICAgICAgICAgICAgICAgIApzb2JyYXRCYXl0aWtpIGJpdGlraSA9IAogICAgbWFwIGZzdCAkIGNvbmNhdCAkIHRha2VXaGlsZSAoLz1bXSkgJCAKICAgIGl0ZXJhdGUgKHNrbGVpdEJheXRpayAuIHNuZCAuIGhlYWQpCiAgICBbKFtdLHBvZGdvdG92aXQgYml0aWtpKV0KICAgIApwb2Rnb3Rvdml0ID0gZ3JvdXBCeSAoKD09KSBgb25gIGxlbmd0aCkgLiBzb3J0QnkgKGZsaXAgY29tcGFyZSBgb25gIGxlbmd0aCk=