content: import Aoc
  import Data.List
  import qualified Data.Set as Set
  
  input = "sayndz zfxlkl attjtww cti sokkmty brx fhh suelqbp\nxmuf znkhaes pggrlp zia znkhaes znkhaes\nnti rxr bogebb zdwrin\nsryookh unrudn zrkz jxhrdo gctlyz\nbssqn wbmdc rigc zketu ketichh enkixg bmdwc stnsdf jnz mqovwg ixgken\nflawt cpott xth ucwgg xce jcubx wvl qsysa nlg\nqovcqn zxcz vojsno nqoqvc hnf gqewlkd uevax vuna fxjkbll vfge\nqrzf phwuf ligf xgen vkig elptd njdm gvqiu epfzsvk urbltg dqg\nsfpku viwihi fje umdkwvi ejzhzj qrbl sfpku sad nawnow ksnku\nnzhj mfudick ueaa jnhz kpy pzk\neuiin xvl elaoelu wbdd xlv jtm nohtq gfdbgdg gdfggdb edtym\nxfmkn wyww woe hwysuh gjw dtk utryasc dela eluk vmmun\nnmag qfwe cwslmgd nlhf hpf\nifs sszo iod isf jna\npjptwg wreera leyb hmlbpf qcrbma ylgue\nrwlpo jhla rprxvgs quguh pyybwgl qqvcb\nrxtcpdy wmpci mpcwi vwvdzdn nfpnj rcsxinl itatg ycy hrctg ron wveju\nzmkfn wip pyiz pyiz tnyg dvftf elks ezhotbj wip\nsgmtfdd xdl sch sch yaxzh wphgksh knzrixp yaxzh etm czqbaa jldta\ngnbr rnpd upe eeb sbq sbq oxc rwvugoj\ncshk thcc emfxx emfxx pbtcf jpim vltkqar czy iudkac jhpcc nqs\nuzbvx fkiuyk izxdiu yutntvn dixuzi hkyfnud oyz ynutntv\newl mfns idy fphu yqccb pte unukirt unukirt fdx\nlzn tin fgena qbql qycbdw gbtn lctlysx adhjfq blu aiv\nites ites pbxzunl vljzh lqgerta pbxzunl\nvmk wjfzvhn pqkidze qfwh\ntqprmc exypl caf kwikh mdyyljc pbo hhxxo skna\nsqxgejb ejc fvup hpesvs luz fcxqwhr ypxof fxlcp pxyk xiczjri\nvjg qcw fsyqaoj mxf jha feclqqr vzdqnk verw mvmvm pvdqtcd xsfu\nfwwn ktvdh aecfv acfve yjozxwo cnujw bcgde lphnk knlph bqwlqju\nuwwapm dlln uwwapm uwwapm\nhuupab ewetcte huupab ewetcte\nwjs zipivpd klwafr ipcczg wbv uujstsw hykn\nmgojdyh hlm xruta lbmaxit pabqrnp vkyigd ptpzr glin gfau pbo\ntbwx baqxq vtz jwex tvz tzv\nefopwx wfknzb ogaxln tqzrh jne zugd zpxikma\nrdjsa arjds hqdldw fjrtl midt qjv jfrlt\ndggqohj bidaaty iah lgmug wwmlbc lggmu laonaoq erkqrb tqolnns iygv qnonlst\nmsc glwn xjfnij itt pka irrafjd euazydj silo\nzsyut znsht ldky zsyut dzcdft znsht\niit cyteu pib fgvrs iux ffctql pib zuzp zsbb ieoi\nxxtwlu kqfxjhq isj xqjhfkq dohrs haovzc cgfwfrt munqon vuyexz nouqnm\neptpqgi uiflvd acj livzq ejtt bniud cjdh jkrcken lspfy tpxri zibj\nzxme dpo fumup gly bkdcwxn lsly eglhe\nuoshw ijoyiql rcskaa vjbqv roiinzi fppqdu\nxuw vdbxie oypcx khxq xebjt oypcx uitqep vdbxie hoz\nlrjv tdksk uebo wktebvx nlapmp udhhxh uliqbm cklyyf jlzw xrmdlvx\nfosspck fosspck fosspck qyidyur hxnxmb dkpj\nrmrvlms susvos idw hzy idw tjgxbc lhgqxr tjgxbc uuq\netjmbdr hwqe lnfwzni lnfwzni good eisci etjmbdr\nyqde bmlcc yuel vpyplss vyvhho kslgiu lllhc jtkijdj uclz hfbqsf\ntlohlvv tlohlvv bdqahw tlohlvv qavcqrn penia saafy\nlvtzyt qffe eaikhv eaikhv wbnl mdkg mdkg utfrm\nluowwk magp luowwk oyao oyao hsb yms\ngnxply vsdqum nprf jik axdp ariqjpc hjqcc\nizbo nkqkb xpqg pgxq qpxg gpm jxbkvu resj\nhsgyxar hvsl ner zzmcn lcpdvqn ern\nrfjlhu xkyh hafs cvvk drg vjsk mymc iab ycmlubx kpwemiw\nwlci qhhpr vhpr oyrili cnynh sivdso ldjya wilc ioiyrl\ncdfwd mbtk sienxui jsmxzo yxbeyl bybtc covxaq yuxn ktbvztl ktbvztl rcekjhk\nptenhqv tzdt phetqvn mfkdz\nhmezeak pqvqld amsih jxqacc uferfyh nfqjsz rtuqdzz pohcx qia cpxho hgpqs\niygny dluc uxqz nlujm xkdtlm xbdgepg jwn ohl wpfll\nlnqf pcxy cpit enp zpj lqfn oowgw yoxdff ohvcfcf fuvz qkpmb\noydu jlscilm pzxen nmtdngu tslcupx ntdgmun uztpx nlhh jqn llsv\neuyx epn gyvg cwtoe ruyap yaurp uryap obbl ovo\npgo irm ksrxe qotuygd afwh qfhzfsr wafh dqjbwce dzfo hew skrxe\ndpvel dpvel ipljjxs vrrsob iakey uheuu swxu qmnmn mpjkb jqrwfmv jozj\nsempz plzxqe qvyg sempz fejux\ncqgqvg zhqir rqzih vyu fmb mfb\nuejl kjh ayz dzimg yzafvg dem vlogg\nhtfkd htfkd hwykmm htfkd\noxvgq wtai rkyyxya ldkecdv\nlvlrsu rsullv pptnrwi slvulr vxrk dpzti\ngde ixwoz nnsx nhc nzi\ndsadkj qtgya wco psyondq jayad crc lswwm purrad pof\nnocibgs hxqdejv nlqxdpu dvzd\njfaws aiwnjm tqjpgs fuiobz gwnemv hjevs xkbbgiq sakgv zmwpkuq grjllw\nxrr jwhtchs boaqkg wjhdr xrr\nvyapct tgw juzgwkz odddvof juzgwkz\nunuu kubdd dxr drwg\nqpefzz iemo fwa vhdcxx\nhseqy copss gytzub lxi mrxtwc hxqqdfx ijt kcy tafjs jit\nuevse rrq zmwyjfe xljx lhgnyzt rngvwqd\ngfvpyhq xpdhind eocgpiz ebs pcmsgjy swni iwns thspnh yvbzxz fgb\nhxr ehw ekfd ncxcs gxjmd oqszdjp fgu gwuoafw zumenf qltbw whzuxov\nwfc pawqo pim jxgt dtiwzil hdptivc slkazm htafjih hzheez rkk amy\nmgoatiy pkec ddvwyni zuya aqrcjes ubkaeus nuhhad upe qfem bpcc\nrmyeg qfq bia lzk fusqfb ltvgry vggr xaxi avwdkbg zhlzt\nzkjoeee dyi sxdwfqa irqljmw gek dgdb mrakr ddaznn zlh ajzzacf juv\nkmqcy pohbej hujdgao rsxfkn vlu\nscnpa hvl cybql lvh lbcyq msw deqqb yjpsndq\nndhjooo dpf ziey jtjlc eesag ldhgoif\ntysbae wkpst kjz stpkw sil yetsba\nghvlfq flhvgq tgkjie gqlvfh\noimn vlmsljl ocala vokhrs odyv msn dzly wcky\ncfjwmh rpsdor bttnkg jxenm mwdk mer jgsusdz cslf\nialvxk bvc qjfikr caw puhmmfl xpmsx\ntyoey egcf dijg vywd enued uxkshz nav bdrn hjugffi iobqwiy\neykhxck shpfjhk vlqg alkenz kuj okxs oeth mqbr nfvqvkv xfvyi mboo\nzbw curcajm mel jxqcw mpdscxq rhadty zrddeh wmedc wkcwt yvwm\niee hzeofmh pqlkkb azlam fpj hzeofmh ripi\nsawaqek oyoiwtb npq pisadk nnd bzgo wiqme lxnvn\nobqx ffiegn obxq for xobq\nzwway wwazy aqxg gaxq\nebssilw nuscati mofyc sogyacc yujmdwu ehxsx qcaf udvoo nlcfaz eov\nvnbe wtzzjn bczyxt crmvas zujy kukq zujy kukq\ngvltk kgltv kglvt zflikic\nhby pium gut fjqn sksoqyq kcliapa\ntbonrr prf vga jqgw ulze ukfig\nzafixw hia omgwoi noeiox fqbket iviidgp bebune kwcuotp slvy wcx\nfjq cyecn fhxvj byv kojvj iaqd aaxva rkogp\nvqbbt sjmr mxu mxu rlfj yqhtzv cuar yde yrs sjmr\niyxiyp auepgw dtpbyvu thuoai fpsfkpn bemgbsk lni ozy jogp xldyvvx fpsfkpn\njtha ibn ahbkh xzxkei tql mycvmyh ioyw\nmpsc pvdiuu wqixxlo cqwmlrw cttoz lad\nsrl xxlnofu dqf snxd zjlp htxzd\nfkv berlbyh kyna wkme qjzgh thpw frup\nirhreaj udkpbza qmgp ormlipa lbyuc\nempizc apcb ossmtj awk ttsgi bfoymzd ftx jkicph qqjv tywp fwzfe\nzaqkd ysn zaluvs rljdk ast fjp amjqr uabrya ufswzjg vcldkxt hzsmrbl\nqvy tqgnwj akibr tfjevhv vav\nmhe sxg hacoa emh kasf hid jklfy ijk dih\nqvwbenk akdctm jztmsx aqvpodu vmknns nck letcrk poba\nlhve kkvff iiixid vtsun uvgte mmlxk pgd\ngktphd aaoqwz lrvsuw ofcyvmi suvwrl dpqiol wjgj uqigjx\ntbp xoc lmz dyzlvp bjleh pxj xjp xbil\ngpzgvj tctszm tctszm pnp upqtmm rribg tctszm sllsbr\nhpm qvjnd lyqg bybpwn etz pwfigbg uqgrvpg cvniubo\ntpowus bdncyxg gmm ebfg zwoue izgkwtx gmtfeg xvudp xgmjp atrvn aqgl\nwlrxvo wvonohi owxlvr owhnvoi\nknyo aiixyi sjtqb kukhgv qkj qiuefb syhfc aoana okmot tdsmnoj eyzqjn\nszhto szhto szhto fxpsavu dtcz hnwqdvk iza\npoykme rboczge tuyiw sxr\nlpgbp bpmf aiqy exzqt gxdoow yjp fxwdmt eoklc jnps zbnbiwr ppvl\nhuecy jjhyz pwcea ffofmj tts\nahbmkw brz xdenmw mwexnd ncdxgf gcxnfd\nyhfnra vqljz bkyxzt vhtsyde ysaxt qbw\ngqhiej rofhmp soeebdp rcuiblb rcuiblb rrnh nses\npxrwe suil iihzf lhcgmfm mqasxh ttpp kqitdyf cuabaa\ncxl cwsp qyseogj dimvv igsoxu ncrexla ubrvpp oum usluv\nrkmo jqqcdjb mobqcta pbcmoi afjlh mork\nnmohoeq fezpxh fezpxh yec\nyxlncrt ivi dajo tjpim tjpim\nhzhy rcjs uhyvwz tdpxlqw itoiyf\nded apfmhe stfk ugyujv drwks zagqnw mbbzmvc aoupemq\niezre wivdwif xzytxe xwytd vpnol pljx aot phln ztncw\nozblu asda tkxh xqe pvijnl qwwh uvp bdhtgjt uynwtav cdz uqmvp\neukgtsy kdfb bdfk tnv dfkb ewdemb\nrsf cxnk cid qsa zwk oetnggn\nfpq oim zetbmlk fpq oim xgv cbaj cjrqm\nphgldt fhmkc efkztj qidri vsv bvjf lfwfgm wfuoln toamg wfuoln idrs\niuc rrdnk rrdnk asqhnz qxkigmo eeoim mmdtgif akk\nrfvsyy kopfhmd tnv ibo demeqm gxrxw hwk ukorln bep\nialo eogif sxlj xfegx nanch egoif eymwt\nkttrpjq gbnyiat kptg oarewx vkmt gbnyiat szyokf\ntjll xviodi tjll efc rliugl wfbbpq wsqvdli jur tjll bguqyu\nuecm yzjhn vqf labnc xyaksj\nhjtef zzq ellr wtrodcg drwqo ernt uzx sqiokam\nizmh ddutl bdzft jvfthh\necr xqrp qlxstu kgprd gqvtwni mkughf bulabe bvoxkx\njwsna vjwq swkycg cpp dvmyal xotxviy qkiva ffa eakwp fww yirri\nufnl lpuxw rjki nggh ajdkpvo oeuaemy bjisma vsjzc\nctxu aavlw rap fzxtcp msufn fzxtcp sdlaom vgvdvpc\nrftw cyf twyxi orifavd\nogiht ertz wcw jnqdup phvp lbw\ntplpyq jeh aobamqe bvaim qptac gssi mkjbaj\nnmklyg iitx iczojzr vjspqb uooky uooky hjk\nggnekbb bnebggk sepzjd fvqfgr\nwnfwrn yaiogv mbusuy cpbcgs thjea\natndjc dbjgdz guedeay rasa kfhame pusuu dbjgdz\nxivzyml xivzyml eqsykxo bshvz xivzyml\nnfe ayx gscy ylyp oqyl isatnpx poaelm zsrw dpd eyrdjpq yllk\nfeqktz mlm jhi yxigeu xzqa qwv yquxw emken jgqsp rojfcu\nruvfcud poubal xswer hfhpyp guf pzgzoq pzgzoq jwgxafi guf kqzzlu apg\nrxwcsdc rxwcsdc ywu rxwcsdc\ndmgsey xrtx wldwyxz avi\nyxnqv ewlx fvif ozfcbxb zqapa yudqksk wlxe mjpvgz\nozoa ozoa hwkbp ozoa\nqcv drtqn uqv kcsavgn ybzs tkw\nnjmloq wapa srm srm ifurca\nezm ccj rub yuaww xhee liikjee kcabgic sbgqx vrpyo pzmesdp ksvv\nhycyne raaksm nylsc lcpgn akasrm vxwoaum\nzhugs pqquitv bae lyozb fhij pcdcc bae rygsgm pqquitv pizz\noxx bzk grpis qiqljwh svkn\nqcq qqc fzgn sqg\nlclad motw ukz zghp\nglr okzfs zgv ygsvv sauuog glr amxr vvmwmu khy eyh\nukpxpy rgnqyaw ncm coeblf\nqdbr ortzo spvnrnq uomtj vffbeva\nmiwar bidfxp eibo qyee\nyldec ghwj mxlemvi imac klkvmg fekxhp kevlzfr fcgnoq fncgqo\nhlm vlol qdic rltij nlzxfys rzpoh\nkrpwspb yrosr hioqla dbpgzgu dvkvvc vvdckv lcjzb qbsbr acbi rtnk\niqtvk jcldzuv smly whmnte mdwlse mkxw mfnkv mkxw kes owkfh\niwcjmkt rnb bjcdjl furhzuu exs\nkjwu iuaj ixkujoa jzeau whpn\ntvj zrdy fwsbagh zrdy czuzum lxotprx wbohaai\ncrsyzod jouf osxntw iwzzie bodu scze gjxn vgxvqo gjxn mmthykb\ndabjfb vjqz cvr gsymwoe qzpusj twvwhw gyvlqd kdrdkzm bdljp cvr\nvmswdz lgjsvxz yjkgqkg tzmjkfp uzbmwxe kuqa dzomt hep jjlibs oxvpvq cix\niqgd btwdjd ncdrovj ltxqc orwhdlo orwhdlo\nnxro uxj ovgha elvzl xmlzssr wonimvb urecfx dbfn kope\ntbes cgyh fypswue fgxjqtd dxdrfm pzhnaeu kugspa\neouzw qrpokyb fyhpb bcvfvze brdwey gpaa fpqutw pbqkroy axtc egamku gxk\nxdrovpt peeww wkcin suir gvrbix\nhgsjks juvod jtii iijt\nyaw hzifa wpagkd tgvmc iru yyeuy mgcvt fhiza\nlsk lks kls edypaxo\ntjz qjs mgoyd gomyd ztjbex nprwk vvw rtjsq quvf vuziqtb oygdm\nkftodz xua lyxt zfadf fgdwt zfadf xua ehwykd wniahd mqoarg\nqgiapb xptk iscyf zfspn qvrpva egufqte zfspn hksw xwxrs dkdruku vegfs\nwqifs wfsevg iwnjjpi oajju tkvhpl lemuw\nrzbmhso pbvb lfgpq fzjwxxh pqlgf rbhsomz\nufi aiyd gxozgx hygjp dtma uughdc ojumcf yuadt\ncaami tqzkvor tqzkvor tqzkvor\nvhtnvyx myxdywi mwpwq hjxadd qkcj vvytxnh dmbea\njvjtcjg mbiwyad cup xkrfk puz uxpmutf rjxyxyn mfchc\nocrak zprfbgu pjjzl zoehfkm xqn qki uxq tcv emknqjp wvmkas\nnxg myr myr vnfzpoy\ngwu ezt kbmeouj sxue cxax gcquz ieegnal xecusia vxf\nxermi xermi qporwc mzemns ticltnz ddpsstr ddpsstr slgbn\nxnujwtw bvzv xjwntuw unxwtjw\ntipo akp fkmcls wglmjq fnrtsv\nfan dfbya qrp lcvxqqu ldpm gucmeky mrzy fixaph rygneb ocm pjh\novtrqs ujmbnal geihpe mijhy eewuic toaxbp ipy tvb evlmrtd lbujmna\nlsmbwwd hvurk ihbuek hvoyq erzomhn gue lpq dihon dgzvst\nfuoshq hfrzeu zfrhue ufqohs\nicgwnbi gmhogxu gmguohx toixb hfwj haxlav hbe jdpxeyi xtgfi\nvfakk ioil hddqu sdztx hduqd bmiuyr vmas\nmcvjjhf sfgt sfgt lambvp dnqc pfecquk\nxgr omy bmoadg afbna mar nicpazd iveku zdioyo\nrpipon dwg wgd pironp\nfkyx wjefuy mfesst ztlf gnnceb rsbvuk ckilt kliqnm iuifcvu\nlmgzx oknwr wmttry luipa vcttj nuqdmy\niota efrxkk daqzm certtoi nnvqrwz qrqgza tllwp efrxkk\nalde wqmdjy erh txrtqm zuljg hspbnrd pvsnebh bkue pvsnebh txrtqm txtthn\nhgggm rswwfpj uctzrv bylqeen dpbnw ostsjwn jtjiyuh ofxu mmmqlg ayhza opbgdrv\nqmhkh orbeokv agosach lhujcju jzpp wmxtcy jcxglu iuwmzrv xwkgz sxlzld\ndzcdm lwal xpujjm xpujjm lpfojz lqqcon qmqrg\ngmwugq ceslt rxcogaq jwkraq\njoxr brdy yixlou brdy lnr lnr\nwbut pxlsclt igigapq zeacg jxiezn hvws wwz ujpbl fdjtfjw opod kea\ntsodswf pufo zqrt zvcpu\nnyy mrqmg zkt tslzsf zkt\nhxywv lbmogd hhv npyzgjy whfvv mlfqjr ggjz owijo zmesslo gtvizw\nxzz dvpzxbd wxwlp cye rcqpgrr gynzo nhy gzpk fpfmb\nnhaakbv iazpdc yadqbe kmqm dffq lidnh cegjosw kgd hwivd wijj\ncwmdyf huoy awihev qav cwmdyf rdwck hahj pesfyk uoju zrirjdu\nqabl vwcwbb phnd xnp huuzwxl rukbp kod sfu ngcvgrt buncnfw\nregyd gjzfwf hpuv zmm vphu gwffjz\nrdf emo crsoeo bksetj aqfzm pphny\nopbmboi iakvj ymjwm vxoq qvox yafk zkch adlusz\nqhm jul zasv xhu qnhjwzx\nmjmyvd mezfuls upbdpzw awc qxta bzrx tjpjmj dxfyewc zorm\nbko kfokm htcpoqc liuvj xhmpcu ccqphot dthvo pfj dtxpmu xoocm cmxoo\nkxv eenns qhpfsvo gqoyv jzjho aoscl fetug agxmfea aygpt\njavmegf jlmt epdwy egfs hwv uszcqvn foixpz iukh dbuhqgs zgb\nzrex zrex xtx ydan maomp hqdhh mfvan broh wvwhqbu\nphatsot joipm pmniq arqzmbe vurl bgy iwbwk oyhngcv vnzbzgm bgy\nxprufgn vhca nrs abuh zwsxmhk mqrj tyslsij ojkdzom wepxg koodzv ypvyy\nvop nnpz mcod mlli ntyhz laqztb kauqkla gmrfte pcuhaci\nvrenj lypors prknc djbdkzv amofdx\nlgig lojnrw obusoc fkwe ggnv pydcraq bvdivl vev mrojjs rxa\nqeg tap jocwlsm vqxa lmjscow\ngptlrgq vdasm erdc oparmw\nrgbsa nacqhvm pczf anupcp upudwgp\njbnobi ifhzrd ihrkkf osw wos lrnwv\naiuntpl fcxpmz fplacs fplacs tipm gfotkx\nfsbnd qoc ozmbi rqv fmbxh tuso kfoxvjn ocja zzs jwplx\nmuaklvq ghozoxh nwxbh mgoou ufptl ouhh reyuf jougckd dgprag\ngwbnqwv dtrd mkzxinl erxl zmfa skuu crxmp wwao wwvdpk nxbn lglzy\nqeejk wvnypc yfzyfcr eeqkj\nnmcp fmkgfyi grfthau azw\nkkallxz rjke ukbt ixkhfb bktu jkre\npxj mnwe djrjde gpsc enqz pdbydx cktfs jjeddr\nmgplj yyunujc vis odee ccesa yyg yjcnuyu doo utse\nflyy juvxomm vcdcyva lfyy ozxnuzw bmgns\nkmsypi zpbyiv rrycnb qos sslwyeo jgbyv njltzt fuwk nwfb ozcf xqnf\nsdcvgmy sdcvgmy hzv uyq sdcvgmy\nfyox vmgxahj ywaxbmm ugy ruwc mys yrjwr ozsxb vaq\ngjpyc sgdn kgm fbvq cziui nzy bwu ezjkkus jrag\nkxcr tgjxss xkcr bembjv rbbiw bwbri\ndcz rrhvdc zbonfzy ubjt\nrvq yjnzswt vatkopb xlj dwxig dqlt qts iva\nlylclc jptz rbidu lbt byxk\nlwre vwriwh afixsi vwriwh\nkmvbflr nfptw fbglxh pyas dxmn hemf segaz zrs\ndvbey zmj xfoi bma udtxhb\nyryng geiwgz bbrvjp ala\nolzicp olzicp qhhslry olzicp\nexf xdmwh xdwhm nhjsssn rmlkdb excguia fex\nxkwgeso htys sjdk jizciy gjjl phgqdjh wzdb izew zcrumu llxfp\nfrkohf oifsm aisebkt ijsfkot ukk\nkoqf xvoior tpe erfpnp npnx\nsneysk nsxki wpmhd mdor akrpvgz moicncj sbsj owfhj exw\noqqbvk xztx gtxlms icmo\nlfy ltq dlzqlvi ovbrsa gzm nhcjq umbtgm nhcjq\niuopdzq cqaeuu xuzngq kxlx laml slvvr frtml tvioiez vyoomw xickbqh\nckahov mepeku gtaf gtaf\ntlto cnnz kzsbkjo kzsbkjo\nkqf comkf dvrkyl jdsqi rnwvb vxvd pok\nhncq xcx yuykfs egrruvw yqh smcou\ntywyq xeq cix yywqt jhzptci hybcoe\nzsw zsgot wnu sumd azmuos qawjaz rpf zkxgwdu iom igh\nvmxmelt gll ysbbt yboqoyz ykdglk cnypf otn owsz ipn epfeka bkmy\nwxjpce etzyavi whb sxzft bfu dgwnbgc nfw sxcteis qqpk\nkofv dgoyme vlza oxhbo lrqt uic tvfqiyy iaqm afnk\nnsmpg wkibdcz dxbw tlxzm zgwe nqwjji eacbhn blk\nshlgws eencr rtufah kjyvqw transt ecsq otbf\nobs xsjceex ffqj sob djpq jcda zlskve\nrfqtle klarp mtzrx rasr eisqovk rpt vymibt zwrif ilsnd\nldu ffd ldu tizfexr fwpmyan\nflxso tzec pzn flxso kzdouon tkvkj\ntvd arh qywql uev btvnpm\nwtwx kzafvk ybyzmhv mdbrphy vamlvr gbxhod tyulba krcqj ikotmla qfhpa\nbnfin ebngj agfdfzu rhjtj aaqzh fsyp nilar uwurjnu hhmso hhmso\nuanmesj vshh syosjdt xkormf syosjdt ifvytwl qnw vshh jkg\nepyzcn pgdxgye lecnx nebg jzdhvge hfy imiyft\nzonbcnv vuvg sxtuty zdhmiow lmud cuegzg\nbxgft mxhzrh unqd pqpsnce khykn qlb oujdxpq pxrd jzxjuxr tij\nqss mqirowz ijjswjm jjer utwn kuedqxx bxshuok qkfag dmfwcr\njgln zdohd xitfbge xbokj xxeuv wqhvhjo erg cua fhc mhwy\neuo ousht ipxt tpzq vnbmlo wvbjpb yjg bwpjbv nzvsea aerhsqv\naxhmi bcf zdx vplso xhmai qsk psolv\nydnpmyo pfba zmo nat ykwxvm ydnpmyo rtd uuvqqr hcfccbd rtd\nytp guw ydmyf rww oucmpf gemhpj labc\nedpbefn awgg qzpe aat cupig\nmmi ghdaoh ibx fbyj gge vmmssen nplt mmqcra omcvm uwa fxypxfc\nkjaw mtijne cfmsigd zwcjjd ajxjlqr tbp bnilc\nfse ele vcsyiv bfe udny vznrao mgrjfgw\nhadl nikvvpf gmdg bkmgt ugj\nxkis qmr cgz nresp gms zrii coxkke vfsqiil\nwmicbf bkk wcwklfg vpcbeg kfmjab vabc dax tnao tnao fvvzeyq fqm\nbct tvj tra soo stqao kqua ikupoy wulcu nauxkkb pvqxy bfu\nwpz txdduxq gaehfki kxo lvjzpxu iqon swr eyihl nbbec\nfuphnbj bdtz huwu zdtb ilgzpa uyaut vpy viff tuuya\ncvusbh bgy apsao qsupha\njtzlbd ljfvh wkjrw xsah sef jygb pqym zbcwok zdmug qpym\nhbibuax iorqc dqjrs daeb iorqc qiw sagyt rkc sagyt khbr\nshz mgn pqrdbm jvace gfhnq ann zosq wdwzmuf kswsg dzt brlavyo\nqiw cdvwds dckpruy pybjra lfvgfn cwj bajtud pojehb rzrzvwe\ntxfyk zkgeeu zkgeeu zkgeeu wskcv nccoz\neettnxq gbgr uiqonyz wqtgs ozfjbn gbgr\nsvd thmmr rbbtxn sxkq isxlnhf tamdlbe bqrgvu nmpvlkc spko\nqmn rspbjme ikjddkq kdb ugpegi egipgu\nufffijo revqpep zfw kwd pnya blqo rnntzx anpy\npiaeyf vbeye uuqd vbeye\nhamd hap ekk lgla twto\nisniinr crz sjpmfxn uskwj\nlzeofk tavbq ijcglqy lvy jliqcyg lwlip\nuhyyyw itlrf tdc iabeocv jzwnjh vqxll nefze pyrxmx eispxnm hzlksce\nucuh mlam bhyej rgzkew ctbo iswqnvg\nytmb toppqgp ytmb gqgpr gqgpr vps ebv\neavn atkqltv bjvojs kaskr vqltakt uiktr xglc eyb rkkas fhnf eaorqm\njmfipc ujggeh hdxpfa xtab ydkibi ycxn ujggeh icheh vpznael oprbf\nxazqxg khlemu awh uwz vhnixk vdcty hkk\ngcl kayi hfozask grpseyn zviy tzoum qywnr wqkhq\nctrrcpw wqfbylp wqfbylp wqfbylp\ngtk lqohf hqeaku mdj zrfkmxn bcqgf msing\nluhpel kexokpx vojap ldaexs bbbtz\noimnqb esg zyjmbfh dfyhcf khpo zjtgm yelztbs ugj zjtgm mxro xyfxpk\ndgtsu vvk wwfugbx aai zlxab beyxcg bpx chc bnxui\nirrwbo orwibr lqt qtl tqknh\nihjsg ihjsg powwy pycyqo ihjsg\nxdcu outh fnqrc eihkss bdylm sjunib eihkss\njpnw ycimse rffu ismyce uhxl feai\nyyodnh dvwshkx vulh pvxj ydhyno hyodny\nvuuweg pfguvyu orhei orhei wrm amkr xecja lmnveth\nwriwe xgtnvj tdmxf gadtqh bezjvz lifu\neuft tchbm xmtlwji tchbm\ncfi zudn zludl pwiu axe psed\ndbtfwf ajxcudj uaxdjcj dxuajjc zouyy\nfmycmej bqhe jyfecmm kkrv kcdvjoy\ngrtb uzs rkxzt hivhic brtg hwyc lsl iivhch qbcp\nymn xfpka hqm sldz dblvsoe\nqrcapma hntgmy difrkpk difrkpk xlsph\nflvqh akcw boxrz ywhq boxrz esnxzv boxrz\nzrvh jskaw mfs fkj\nabveb qxfnlfq abveb kbwiyvd abveb\npgarl nbfrenx rnxgx bdlkix liltdm dzcokeg fubupcg iwp xfayp obfaz nevfw\nnuhvaci blyv fcsp adlanka sjy syj ysxl\navwakn dkoya yzuszuk lqrr oqfyd dmgbhd lqrr\npxa mcvtoug nlweso yffqc dtuagcd ovvrkz ggfhw wnlseo bpqbn ohxzs rxzo\ndjkcl kbgyfir ogquot uoqotg jtmyd ohudvle xrnbt yvsln wykqt hntc xlrhqrb\nykt tkxfmd exas kty\nzebstke msbbndq itmli ubexmht vekvd xbmb iajbj wac sta\nptdg oftwo goiulah tfmsrqs jffxvnv ozaluj qlhqjy wyffa\nxeq ezmlpw xgno xorvfo yzq vwif wsi\nhdove hqbzhu pjrxlj uafuh rizlb advmkca\njzk ddoisdh tfjh yuvikps ixpkf hnu\nkixa djx uksr ogxty dxj clda ukrs\nxgiy diwbvn vphdbg qnelyz tqptqig lenyzq ecsswj\nalx awj fpasmmg zukuh qaanvb too nvskuk too gnria\nsuo suo brw nazq suo dqv\ntan uxiz oqa xyezcd lsaicjr bosiak rmmh\nbidpomf dimcj qekero wbrc lewt kmgmlao\nbciacj eye lxfpef cbdshd dhdsbc qwnhil iuokc\nzduefht lrgfjn nclksm wpjpjr hkeqd oprsjcw\nchhdr bram swdfjr yikqra xkzsloc otptp agec hhdrc uofljf toppt wpbyrwo\nbwlpb nishr knnrysj bvr ftnb iedskch weo\nczo hsfp wblh cru kzalun intt\njvob rppz rkwv hgyhrqg\nsgo hued jnygge izf ztan kjgpcn fagff jsi ijcxzoi tgqjjp tgqjjp\nltjq zidjy rfmy yevuaa nlhfyg xytdtle wsqvzzx wfflboo nawhv golhf xhsti\nbmtzlml xcbsquq vnfsux voep lkss ioim\nntfffh gcncwu mmymn wkwlswa gcncwu iaeyumz\nkcgdm rbaau cwsoya pznnnn xzz zbbdlhw zxuelq xzz pjeq\nxrmnuct kwvykx khxr ioua xnmtrcu xrnctum ujq imnt ecee\nxjsgx fby fby fby ggtpgdm jqvuj qshewki tkml ymsazcq\nsdbyhwg kewtrte novhdcp wbuaoh dtytgtx zez whygbds hpg\ntjvaqo yrycda yrycda ldbp yrycda\nkloi tmsocmx dza sqtxc wgevs zlevs vtm\nftnx drvdm ryjfdgw nerynh cwfjpa mddvr\nwsqjyn svg ncw aesn hvuq vybajti aesn bql atxhp ipu\neye romgxj gumuke jwi jrf dtt kcj wmg waw\nptltud oymklv fgnmbc ete apanovb vpt vyospi\nclkguhu rbxs lxtnmy ferdx qbmrpg pvojnj zbcffbp\nitngp dvtlq fzxp cxrf gbxxqp aafls pfe bpxgxq\nnmikrui ddsq srfilr gnuvghu mwnacz nlbdm zcjm uylgev umzu mftz nmikrui\nbow jmnxyen bow hvz\nlksibxk lefzh lksibxk nkxsi nkxsi pldvhk\nosjlzns pihvr zpeu zxjgjb xplykfk xplykfk\nhajmfss cardd kaddjw uicfde taue\nrgwdjra sgifh ggt mpzx usghkos oob fvzx ghnyxr sblcif\ndtu gnihpry kjdpiny xvax itmluk fxvgaap bei xuq wzcy rhb hailtgo\nwwob ueldq ueldq glxc umimwv onu dxhmhis ebottoa lnysfiu\nzfbyi eyq etaj idpbkf\nqshcfjb ozzqigv raztm ymcv sgivwoc kightf dcaglk udah fdm\njmxr jrcnck enffwfl jycc jmxr cylnigo enffwfl\nbkslhv tykqw tykqw mbeqrbt tykqw\nvogf nhqltpt nhqltpt vogf kpc\nryayz ddktu rfhkmx xok xninjcm ijcrw fxu\ncmezfj zaamjrs whlcuoo mug lcaqhkb ymkdci qexa onhgk pgy\nhcrcok qri fki wbiog ptj pmgtdt\nxsl mpfxwbz bmzxpwf hrysu bmfxwzp xfja\ngybzho ktokndy rzkbr jcnp ahicq weccg pgrodkt che vaglyn omhmpo\nvdv bngjox srs faymg xrmf enseu aygfm gvsd\nnuzi xodkbag eevovl bfjuv nuzi xmejqn\nkcswegw bpa dgil insf insf\nstg tklrut poi knurfpf\npcs dgirfie yep lvkfk ype hntt athvad clfybsq ofjhegj epy qwawns\nwjtpgd wjtpgd vxnapp mwyfsm vxnapp rvcswcs jksa\nckzslrg wdzeimw cqhp nfgk zgukvd yyt tra erkx wdzeimw\nhsww avl vkmzej hsww\nmum oczj jfew rag zjoc wjfe yqynjqt cbkcsgo mri\nvjhfqdi vjhfqdi npfa pzdmy utlyw bwvbfm nqdv iiap ygpky bwvbfm eocya\newkqi ckb yviuro mqz vtrdam yzkqzv ppbj lhmj blkafo juxvwke lvewc\nljrewgx sutnb hfsavbu jofr ltml mjzkzz nmjii sutnb eonegt\ncxzv nepyrb wmejdo vwqi aeqys\nsbx fmne obzdz rdnfb gmb sbx ykcae hbzom ncwju rhpiao obzdz\nlsgfun cbmfjwk fya ktzxbwt\nica bpsk bwjwkp obloxdx uwoqdo bnnhjuc tlsx qtaacp bdooxxl jamy ade\npsus wmtkg ikvfx fkvesj upqlhfs ueje nyt abxvo\nadlbl hzskbrp ooht nps\nwtcgnvy nvqtvx tvgnycw ntvcygw kkxcp zyjmpbh\nxfxww xsddqe ewvmgw qxqwy wpabtz ppe zuiw zubcc onaqii\nkkaeec xhcakul wrrvi dtlqfy ahqdilw bnt gwimw espaivx nam yfv\nlxz jtc nkwgz nbgsao olsck emtltf xidwcvm lcjxq\neav dzh hnbp hnbp yeg\negaq yvat kavsige csar zsi sptai\npofijc ibdnoe caoazp azlnjk dqp chik lowll iby gpvjv ohm\nors lexk zcneaj rmesx jman uqkb kvkq zfufmn\nqgsyzxd hlm juerg ortfzw hxjzg\nfxwy lcoc fyxw pzhynp yfn zdzrz\ndatmws ckwghgr gbtyf lqrpfgl mbgpd dyjilr fgybt hxpg\nmxw facxdnu wxm urltwtf qfo wtpwrj\nesa srypq jauwv dpm wdgqq hrke icvudq bdmubb ellhfjh ttpjjd gxmg\ngvwvqwj cbzzuvj eckube adqinpa djutlue wcpw vrt ucqwu ekruwsn\nfhj fst zmtb yhwk dxlbozs fcb vjvuxin dxlbozs rixdvu\negfoep cvq icd prwj icyg\naojaa ezmcuf udreyi bja cyrtpl wjl\ngjeka bsbufp tbqqq vbmnqg sfqtgac odhq xzsxt\nyse gujdr ugjdr sye\ntax hntqw phf eixjwfh qkylnu nkyuql ugsuj\nwyh egum zizhfc jrq htbyug lop dsu\nexh vfdoosj ajrna jbiaz lqsgvks xklqgjv abtmdud\njuqc ormfa sab tucsfln detqfo feg kifsion juqc ovhra\nhvcrh oddhme omzmu vmy she xulvfa fecmgi\nayo gspge nkmy yblsj lrsre nkmy pwocjz gdexqqx ovovm\nacy sqcz ijl htt yjsi rly vea bck\nbniafe yore xnh rkcfd hxfuzw xlr nkzmmcs ekwggiu kgoboi wfuzxh hwfxuz\nweq crkeq cccphe dtozviy kzkkdr yku cephcc ctq zbau dewpi\nvfla rzpl bnmx uvggon foivrb fval\nziaove lawkpdn ddwl sxj krroj rqmffxv babb\nbdw dsifr kuueet hugddwt piz dwb sjixveg kmsoknq\nczl feyxf soyvbj tnmpjn kklwi akx nqepntc\nnrmhc tkkn jrxgc jrxgc tkkn\nufzn mrhiapi qrme kjlf qrme xpp qrme loyzizz xqm coli\nqvaoye mysv ydfxr iixrw\ndql tqarux fxqfn haoinu lyati xml\nkyve obatly dgfjt fjz sqrz xlbst lgwlt zovih aepy otrpl oifid\nymawam afgye lcnpkmv feilfws vonseh rxrdco\ntqij kuawg dmova slds imdtb sjsafo ffkzzl pxxenva wuakg efbgx\nyrwoaos vpw ijjpua jnbxl sev yvgdxzr mpqa vpe lboh sev\nkrwdtd uglxtcz mljcgdk lqj fgpfle nuui cqk exr nuu oyn\ndwd nwt idhclm vgkh rpubq wybhapp\nhskhgpy gzvz jztbr jwv vcx vdjmnjr jrsp\nikml ceuhcng biu zoo gra bnnforx abzan hwsmd lmki tsl yvogo\nkqfc younaz azvgfz gesajr tmwxvyb vmcdu dclwh rfjwhic slfym\npbrhjml rsacryg jga qvgks neh fcq qmi mwb juezk mjteeg alkb\npcj ujstl fkrqm eeczrle hbkcvm upbo mrb qrspjt\njbq rrk xjl rgokbnx hor ogg szxqu hysy vqj piorq wtrtrdk\nbnq ntvhcrf vrm puer kde xaxkja sfxgjf\npgcicus hqeqkkx xqekqhk qqkxhke\npuquxi hmeaehh oxe tasipw qzyg hyvy wcmpwe\nhvs fxq wvfy zjepsl dvrfxnc xnvg\nxle crcuc qkhnv crcuc oedez bjw pmwq\nxzzpiy cjwss jwscs apb bpa\nydjhhf yeltadb lwi cjdcb ovaox xrdm vkxub\nzax xza admbc lvpzfeh auxn rwasj\nkebx eild nrskdr meja jxczomh gcne"
  
  noDuplicates :: Ord a => [a] -> Bool
  noDuplicates l = (length . Set.toList . Set.fromList) l == length l
  
  part1 :: [[String]] -> Int
  part1 = length . filter noDuplicates
  
  part2 :: [[String]] -> Int
  part2 = part1 . map (map sort)
  
  solveParts :: Int -> (Int,Int)
  solveParts _ = (part1 passphrases, part2 passphrases)
    where passphrases = map words (lines input)
  
  main = Aoc.timer solveParts
  