import re

def day2b(passwords):
  # one liner:
  return sum(1 for lower, higher, character, password in map(lambda x: re.split(' |: |-', x), passwords.split('\n')) if (password[int(lower)-1] == character) != (password[int(higher)-1] == character))

def day2a(passwords):
  # one liner:
  return sum(1 for lower, higher, character, password in map(lambda x: re.split(' |: |-', x), passwords.split('\n')) if int(lower) <= password.count(character) <= int(higher))

input = """15-16 l: klfbblslvjclmlnqklvg
6-13 h: pghjchdxhnjhjd
4-13 n: nnznntzznqnzbtzj
10-16 r: nrrrrkrjtxwrrrwx
1-6 t: rttftttttttttmdttttt
4-12 l: zhllfxlmvqtnhx
6-8 d: wxpwgdbjtffddkb
7-9 q: rqcqxjqhsm
6-8 x: xxxfxdxxx
5-9 d: dwnwnbsddfmc
2-6 j: jvdrrjchml
8-10 x: xxxcxxxzxxxxx
15-16 f: ffffffffffffffnfc
3-12 v: vgvvvvvvvvfqvvvv
2-5 p: tknppm
11-12 r: frrnrfqtshrgw
13-16 f: rfjmkrqkqrxmfnqj
3-5 f: ffffxffn
2-4 f: fffwf
11-13 s: srslssshssssx
1-6 c: cccdcn
2-6 t: tthhnc
12-17 w: wwwwwwwwwwwmwwwwg
5-6 k: kqkksskkp
4-5 p: ppppx
5-12 h: hbjhqhdwnqxhhsh
6-8 p: ppgzpppw
3-4 z: zzcz
6-15 x: hfvxxsqbfxxlhpxtb
4-7 m: qmxzhgt
18-20 b: fvzbbrbcvskxrpkwnmwb
1-11 c: ccccccccccggccc
1-3 p: dppp
2-6 j: fjbmljmdb
2-4 l: slpmqpk
3-5 b: stbpbbndtgzxlsnbdk
6-11 h: hlzkdhhhrhchmhbhl
1-4 w: wwpv
10-12 p: pmpppkpppgph
11-14 f: fbdxffpffffffkfffjvf
4-9 v: vkvfhfvvrvvv
16-17 t: tmtbztrptdlvttvkt
2-6 w: wwwwphwwwwnwwj
6-11 x: xxxxxxxxxxkxx
9-10 t: ttftchttnd
2-9 w: wkwwwwwwlww
2-4 g: ggvcgggggggggg
5-6 d: dldddsddddddd
5-8 j: jddjjnld
9-12 l: xldxlklvlkll
2-3 w: xwnrwdwndlvl
16-18 m: mmmmrmmmmmrvvmmvmm
3-4 t: ctts
11-12 b: ndgjdbppcdbhhssw
2-11 s: nssksssnssxvq
2-5 g: qggwcvf
10-14 l: llxlllrjlmlllwllll
8-9 w: wwwwfpwtvtjwjw
8-10 m: mmmmmmmmmmm
1-11 z: rldjzzzpzzs
16-17 v: qvsrnvvvwxgmvjjcvhcx
14-18 k: kkkkkkkkkkkkkkkkklk
2-3 q: qqrqqqxqqqq
4-9 c: lclckhcgn
2-3 b: nbbbbldlbbb
15-18 v: vtvvrvxvvnvxhvnvvv
4-7 q: qqqnqqqq
3-13 j: svjjdcnkwnbpl
4-11 q: blnqvqsngwj
3-4 j: dxdkj
5-7 c: dzxbsctqwclcgc
3-4 f: jfhffff
3-5 t: sttwk
7-8 t: tnqtvsztqwpvtftknt
1-12 r: grrrrrrrrrrrrrrr
7-8 k: kkkkkkqkk
3-4 l: llls
1-14 h: khhhjhhhhhhhhh
3-5 d: ttcdddd
1-7 w: dqwhwkww
4-5 p: pppqppppp
10-14 l: lqlltwlllllllzjk
15-17 d: ddddddddddddddddcdd
1-8 z: xpbbjxrzlzznxlz
1-2 v: vrvv
7-11 l: llllllclllslll
3-14 h: hhvhhhhhhhhhhhh
6-7 m: mmgpbjmgqmm
9-13 h: hhhhhhhhhhhhfnhhhhwh
12-17 c: cccpfcccccnccccqscc
6-12 x: kqfxbhxbdxxxl
6-8 z: zqkbtzzb
6-8 l: llllllllllllll
6-13 d: wdzdxdddddlzdtbd
3-8 h: gzcknrxkjgtggnqwqjs
1-6 t: tttttvtt
5-8 x: fjxnxrtn
6-9 z: zzzzzzzzszzz
2-4 v: vpvvtv
1-7 w: wcwrxgf
2-3 t: vxftld
1-2 n: nnxmntsqzk
5-11 l: nmvllllnlckl
7-13 c: cwchccjcrfsccc
2-3 z: dzdz
7-8 s: sddgbhws
3-11 w: qqsqrgmwwmwgfdhpsct
16-17 q: qqqqzqqqqqqqqqqqh
7-15 h: thqthdphmbhhjphhh
6-10 k: gcflljjwkk
9-17 f: ffffffffffffffffdf
10-12 q: qqqqbqlpqqfdqq
3-16 x: dbxmwtlqdmvldxlgxdhk
1-2 x: xxjxh
10-11 p: ppqpppkpptp
3-5 w: wwwwwwwww
10-11 j: xjmhqgdznjf
9-11 n: dxnnnnnnnnmnnn
1-5 l: mlllvllwlrblllll
14-16 q: tqqqqqqwqqqqqmqqqqq
2-3 b: nvbbbcf
5-8 x: xmkxxgxq
1-4 x: xxxfx
1-6 n: nnnrnm
9-17 p: pppppppppppppppppp
2-4 d: ddqd
13-14 p: fmpkxpprppppzhpp
5-6 t: tttttgrttt
10-12 r: rrrrrrrrrlrrrrrrrr
4-7 h: gnmqvqrhwhh
4-5 m: smsmmmm
4-5 q: qgzqb
6-12 c: rdnnsccnrjkcnm
4-16 k: gfkxktpwhxzkgcdnb
4-5 f: ffgvf
6-13 n: nfslcrnkksfmnmvcfnnz
15-18 s: sssqsssssmshmsmsss
1-15 v: vvvvwvvxvvvcvvwvvvvv
2-8 h: gphlnhph
4-13 t: vtjvrcxqwbsrk
2-10 t: tvttftzttttqttt
12-13 t: dvsbstlkfpztdqs
7-8 w: rvwncwww
13-16 v: vlqzjlvxljrvvjvvzp
12-13 w: wwwwwwwwnwdwwgwwwx
14-15 d: dcpdddddddddddmdbd
1-3 b: bbdbbbb
11-12 t: rkdtncbtkktzmvtghb
3-7 n: nzbfgbnnx
5-13 v: vsvbkvvvvvvvv
3-8 n: nltdrmbn
14-15 p: mzkmmqdfpcptzbzc
4-6 q: qtqkgqfmqwm
9-10 v: vvdvvxvvxvwd
5-7 m: mmmmmmkm
6-7 k: kkkkkgkk
8-9 h: shhhhhhhh
8-11 p: pppppppppczplbwcpb
11-17 k: kkkkkkkkkkkkkktkc
9-17 w: mwtfbvsfnhwxqqvxw
8-12 j: jhjjjjjrkjnjjjjjjjj
3-5 g: sgfgqgg
12-14 j: jjjjjjjjjjjjjjjjjjjj
1-11 f: jsffffzfffffxffftf
16-17 f: fffffffffftfffffff
2-4 k: klkwkk
5-8 g: gtjngzkhgb
4-7 b: bbbmbbbb
4-5 w: wwwdw
5-15 g: tplhhgmggbhggrllqg
9-13 v: jvvbqvsbvzhxvh
1-3 d: ddsddn
2-5 w: cfwds
7-11 x: xxxxjxvvxvxhxvml
5-6 v: jwqxvb
3-15 s: ssqsssssssssssss
5-9 d: dddddddddddddddd
5-8 l: vklnlclj
10-13 s: sltdlfbssxsss
11-18 j: hxjxjnjcpmkppnpjpjk
4-6 t: ttbzhvt
2-17 v: rzmhrssrjvpncwqwl
2-4 x: mtcxz
11-12 d: dddddddwddbd
2-13 h: whgpdxvkfxrhg
5-7 d: ddddddxdtddddddhdddq
4-8 b: lhcfbkbbdmb
8-15 l: lvtmkgwllqttgplbgjj
3-5 n: nqngjvw
12-19 m: mmmmmmmmmmmmmmmmmmgm
5-9 g: grhgsdcwgmdt
6-9 j: msgrcrfvzksfxxjq
6-10 s: xdssssssssssssssg
8-9 h: hhhnhhnfhh
12-15 f: fffffffffffffffwfff
3-7 p: pzzpbjkfcczbmnpkf
6-7 r: cnjlbhr
2-5 f: dwxcftrbljgstf
5-11 h: hhhhjhhhhhqh
16-18 r: rrrrrrrrrrrrrrrrrmrr
2-4 r: rxmrd
7-9 c: ccccczccccc
7-13 d: ddddddddddddfd
3-11 k: mmkspkltjwm
8-11 c: rvccccgtclc
1-3 v: vvhhv
4-7 t: jttnttgx
4-16 n: nnnjnfnnnnnnnnnnnn
5-6 m: mmmdmqmm
9-10 x: xxxxxxxkxrx
2-4 m: tmcmzjmvtcghlgm
6-7 q: lqqjqqnzqqmq
16-19 k: kjwkhkkjhkskskpnkfk
19-20 b: pbbpsbnbbmnntbnbbbbn
4-5 p: ppppmp
3-4 d: grlqndd
4-7 n: nnnnnnsn
9-12 k: kkkkkkkkfkkkkk
4-10 h: hfhhhxhfhd
4-9 t: ttttxbbbcdmxsrhjj
4-11 l: npxwbsmklbls
17-20 d: dddddwdhdkddjdddtfdd
3-4 s: nldssq
4-8 s: sssdsssgs
5-16 t: ttttprtcttttttzt
9-17 j: tjjtjjjjgljjjcjjfj
7-8 b: bbbbtbkbb
2-13 l: szllllllllxllll
8-11 n: bmpnwrnngnmsfw
1-5 d: jddqtdwddxddjd
10-11 s: hqgnvslssstqdnvs
14-16 p: ppppppppvpplpgpp
2-8 h: khhjfcqp
6-7 d: fxdpdwvdjkd
5-7 n: bnnprnf
9-13 f: vfffwfffffffkfxff
2-10 j: vjhcggzrjqt
5-7 g: gggfggzwgg
5-6 d: ddbsjddfsdnddxfpgdd
12-13 g: gggqjgxgzpgsggxggxk
1-8 l: hlslllllll
12-13 f: sbfftpvbjsmff
6-7 s: hqcthsb
5-11 s: qsstnssssqsrsskdss
2-6 x: hxrfnjfclx
1-2 w: swwwwwwwwwwwjwmwwwww
7-12 s: whsbkgsmvnfjnnkq
10-12 l: fllllllllsllll
8-9 s: lsssssssqs
1-7 p: pdpppghqppxpppppp
1-3 x: jhxmjhkdrxgd
1-7 b: lbxbbbvbwbbbbt
4-5 c: cdckcbcmqcc
5-9 k: kkmklhlmkkgkrld
12-18 x: dvjxqxxxxxdxxxzxhp
5-8 h: nhfhnfqx
15-16 k: kkkkktrkkkkkpkhqxkkd
1-13 j: dcnbwjxllpksj
11-13 v: wvqhznrrfgmnvz
2-5 m: bpjbmbrmfh
10-15 t: mgtttttqspthnttkktt
9-10 n: nnpnnnnpnh
8-10 b: bjbzhbbbcq
4-12 n: nnnvnnnnnnnnnn
13-14 v: zbkchmmvjvsgkvhcz
2-9 j: jdqjgnnjjjvjt
11-16 g: ggggxqglgglfhvgggn
1-2 b: bsbm
8-11 v: lvvvjhvmxvvvv
5-7 x: xxsxxxpr
2-15 t: stwqdkrqcwbmngtd
5-8 r: rcrrvndr
5-6 v: vvvvvr
4-5 x: qpxxr
1-2 k: nkkkkkd
10-13 r: znlqhvwdvrqbrrrfzwc
1-2 h: hwhhhchhhhhhhhhhhh
3-6 b: bbbbbvbbbvbb
13-14 s: ssssssssmssssdss
7-11 x: cwxhmnhzxrxdrzzxbw
5-16 m: rgjtmrqqmfmmckxm
17-18 b: bbbbbbbbbbbbbbbbbk
11-20 k: kppkqkftkgkkknbtglkb
13-14 t: rtcfrkjvtgnrtf
5-6 z: kdzjxzjgmd
2-3 p: rxppj
9-12 b: mtpbbbbbbbbgp
8-9 b: rbbbbbsbbbbxb
13-17 r: rxgbrrnrrrrrrkrrlrrr
8-11 w: pzqswqwcfln
3-4 x: xxxx
6-9 j: fjhkjjklc
6-7 m: ctmzmfm
8-9 l: lllllllgllpts
8-9 t: hgpwblqkvqtb
4-7 d: dddpddd
4-5 c: ccccwcccg
1-7 q: lvvtpqqvnsqbzqpr
8-15 q: qqqqqqqqqqpqqqlqqq
4-8 f: frfffffffxf
7-12 r: rrrrrrrrrrrkprrtrrrp
14-15 j: jsjjjjjjjjjjjjl
6-17 b: khgflbrbrjbgzjtjt
5-7 j: jjknjpw
2-9 h: rhlqbdklh
5-7 j: lrtvccjbzgjh
12-14 t: tltwtxtctttnttttft
8-9 q: qqqqqqqqx
4-15 p: ppppppppppppppc
2-3 v: vvvvv
5-7 h: djvplxb
11-12 g: gjxlvggsgggxsgfgp
5-6 g: gggggfg
1-6 x: wxtxxxxxxxxxx
1-4 r: rqrcrvrzbrxrwjr
9-10 w: wwwmwwwwpww
7-15 z: pzrbrxpzzzzzntzv
4-5 q: qjqwqqnlqhclq
12-16 g: ggccgzggggsggjgg
11-13 b: phbmbsgkvszbbrbb
2-3 l: xhlbhl
1-7 q: qwdqmtv
5-9 x: xxxxjxxxxx
6-8 p: kvpwqbdp
11-13 t: tqttttttttttmt
9-16 l: wzdxdmlxlkfjknnz
1-11 j: vjjjjjjjjjjj
2-18 t: tsttttttttttttttthtt
6-7 n: fnnncnl
3-5 s: lssvgfssgsshsvstsss
3-5 h: hhhbhhh
4-10 x: tsxxxxxxbls
2-4 n: nnjw
17-18 p: bptpftnxjchrwthtppk
14-15 d: dddddddddddddddd
10-14 m: mmmwnmmgmdmmmmmmmmm
8-9 k: pkpqffpkktbgkbk
7-11 l: lllllllllqplllllllll
11-15 n: nnnzngknbnzdnsnnn
2-4 l: vbqm
10-11 w: wwwwwwwwwwq
3-5 x: xxtxxxxx
3-15 b: spbcxjlbbbrbbbbb
4-5 n: nvfsn
13-16 n: bppjnncnbgjndnnntwgs
1-8 t: mttttttttt
6-9 d: jvmssdkdhxsd
9-10 d: gdrllcfdnd
7-11 c: cscxccccnztccccz
15-16 p: pppppkphpppppspg
2-4 n: vnkjlwwsswscmxktnj
9-11 r: rrrrrkrzslr
7-10 t: tttgqtnttttttttt
4-10 b: bbrzbzpbsbnbbjnbsb
7-8 j: jlljxtsj
5-15 z: lzzzfqzzzzzqzzzzzz
10-11 r: rrrrrrrrrrcrrrr
6-8 t: tztpbttttt
2-9 c: vcgtfxfbr
9-16 r: vgjrwcxhrrhbzxnj
17-18 r: bczjtmjwrtzwvmgbrl
5-6 d: dqgddvd
1-2 r: krzrkr
8-9 j: rxjjjjgbj
8-9 c: cjccccccc
13-14 b: bbbbgbbbbbbbbvb
5-6 p: hbhwtp
1-2 w: wfhrfsfbjtpkqcjrwdb
10-13 q: qqqqqqqnqrqqzqq
3-4 m: xcmcz
11-15 d: dldddcddddjddqd
4-10 h: khhlhhhhhhhhhhhh
2-4 d: bdfpmxzqzbzmxmmwg
4-5 l: lgrbl
9-13 s: ssssssssfsssss
7-8 p: pplkpmkppppppxp
3-8 j: jjjjjjjj
7-8 f: jfffffhzfff
2-5 p: pppppppp
8-9 l: tlclllmlz
4-5 m: mtrmx
13-16 x: xxxxsxmxxxxvwxxw
5-8 n: jknnngnv
4-7 p: ppptppgpppp
12-15 r: rrrrrrrrrrrxrrrhr
2-9 s: sssssssssss
5-6 z: zphzzr
13-17 m: mmlmmsmzmsddbxmkb
5-7 g: gggggggg
8-9 f: ndzfvfkfz
2-10 g: wtngwdkcxgrth
6-13 r: rrqrrqrrqrrrcrrrr
1-6 z: hfzzzz
10-13 j: jjjjjjjjjjjjdj
5-11 m: wfqvmhbjhhnmzdlmpjc
6-8 d: clddzxcdghn
8-12 n: qfqbbvkpjbznrz
3-6 r: rrbrrrrrrx
9-10 r: rrrrrrrrrrr
4-5 m: chltmcm
7-8 r: rrrnprrzrhr
3-4 j: jfcj
16-17 n: nnnnnnnnnnnnnnnnwnnn
7-8 r: rrrrrrnfr
4-12 n: nnnnspnlcnmsnnnn
11-12 v: vvvvvvfvvvhvvv
2-8 h: hlhhkhhchhhghh
4-5 t: stntztttmp
3-5 v: vvvmbvhvvvlvn
9-14 x: srxmtbtgxgmqxxxc
4-5 z: zrlgz
10-11 p: phxkvklpmdp
8-15 m: mmmmmmmpmmmmmmm
1-13 h: mzwqkhhhphsgh
17-19 s: qssssmssgfmssmmpssk
6-8 b: bbbbbbbjbb
3-4 l: rllr
2-4 j: kvjj
2-5 n: lnnkrm
15-16 w: wwwkwwwwwwwwwwwc
1-3 c: ccncc
2-5 s: bhppmsttzcscss
1-4 t: tttxtttt
1-9 r: rfrrrbhtxrrbrmrmr
12-13 s: qplrssssmfswrsswss
2-4 h: zrhhhhzhzhch
1-5 g: rgjgg
11-14 t: ttttvftttttqlsttt
3-4 s: sskss
5-15 m: mmmmnmmmmmvmmmm
1-8 j: sjjjjjjj
1-4 c: ccclcc
5-7 d: ddddhdd
2-8 z: tczzjzzzzzzzgz
1-5 s: qsqdz
8-11 z: zhzpzrvzhzkzzgm
5-9 g: nvdfgshgbgltlqggbp
1-12 r: rrrrrrrrrrrrr
3-4 m: xmmb
8-10 j: jjjjdjmjshqjzk
2-4 t: tptttftt
4-13 t: ggqscfggftnxgjpn
4-12 q: hvzjzqsqwqjlqx
7-8 q: qqqlqqqkqq
9-10 f: ffffffffdfff
2-7 k: kgkkkkkk
7-11 t: xbpdkrtplmfbtkwgp
4-7 c: ccccccccc
12-14 d: dddddddddddqdddddd
6-7 k: xhnntkpnbkfwlr
3-5 q: qqxxq
13-17 d: ddddddddddddvddddd
2-3 g: smglpgpflsrbwxcjctb
5-9 z: zjzzznfzf
7-13 l: lmrkvvxtltcnj
15-16 r: vjrrrkzxrrrqrtrpzv
2-7 x: xsxxxxxx
7-14 m: npmnmgdvnqmgrmm
2-4 x: pxxl
7-15 k: nkkkckgwdkffkmb
7-11 n: dznnmcnssmcn
8-10 s: skssgswssmsss
14-16 n: nnnnnnnncdnjnnhwnnn
4-7 g: kggmgggbggggwggcqgng
4-7 g: gggqggggg
1-2 c: cccc
4-8 j: mzzvwjgrbrv
11-12 x: pksjnwlltskxlj
1-9 k: zfkkkksrkkkkkkz
1-6 k: xkkkkknkk
1-6 c: gccccncbccccc
14-15 h: hhhhhrhhgkhhhmhh
7-8 f: qffgnfhf
2-6 m: vmqwxzgsm
5-8 k: kkzjkwkvk
3-4 s: dcsss
2-4 p: jjbps
2-11 z: zjzzzzzzzzzz
4-7 f: bnkhvjfff
13-16 m: mmmmmmmmmmmmjmmmmmm
5-10 t: kdwjmcgtvtdttmtvw
3-12 j: jjljwjfjjjjjnhjjjjc
13-14 f: fffffflffxfffbf
2-6 m: zmhmsm
4-18 n: nnnvnnnnnhnnnfnnnhnn
3-6 n: xznnsnn
7-11 g: ggggpgggggggsg
6-8 l: llllltllll
4-5 s: ssnttsrs
6-14 w: wwwwwwwwwwwpwlwwww
9-12 q: pxqvswnqqbsqvgsd
1-4 j: mjjjjz
9-19 f: fffffffflfffffffffff
2-6 t: rttqtstct
6-9 d: dddddtddddd
7-12 l: lllllllllllllll
1-12 p: gppppppplpppppp
1-4 s: fslssssssfcd
6-7 v: wvvzffggdfvbvvv
2-7 t: kkwgspt
6-16 n: nncbnnnntwrxlzzwdrsj
3-4 z: zzszzhrqwngprjt
4-5 v: vkvvvcfjc
4-5 j: hcjtj
2-4 k: kqkkkkkkkksk
7-9 g: gzgmgpgkv
5-9 s: kjnwsrjrzssssdlnsqs
2-8 j: jtjxxgmjkjx
5-12 r: bfrcrtjkzqffsjtvwj
1-2 v: xvvvmvvvv
5-9 v: vzrgdldfvx
3-5 m: mqsfmmlmvdfj
12-15 v: wswvvbqqhlvqvwx
6-7 b: bbmjdhb
2-4 b: hbjmjr
6-7 n: pnnnnln
13-15 z: zzlgzpmztfzqzzl
5-6 c: pcppscccccc
6-7 z: zzzzzzz
6-14 l: lllllllllllllqllqlll
13-16 r: rrrrrwrrrrrrhrrr
11-12 r: rrrrhrvhqmqrwr
15-19 w: wwwwwwwwwwwwwwwwwwdw
3-6 w: wwqxkw
17-18 z: zzzzzzzzszzzzzzczvz
3-4 g: lgxx
4-5 x: nsdxdskjxtrz
11-12 w: wvdgqppfwwdf
2-3 w: qgrz
7-8 w: wwrppwfwwrcwr
2-6 n: gtspnngz
3-7 j: jjpjjjzjjjjj
1-2 l: pllblvgmfjvv
15-18 r: rrlgctrrrcrqqgldpr
3-6 v: vvvvvt
2-10 s: vslltcxpbg
5-8 j: blvzjtjnfmjnjtsrzmc
9-13 b: bbbbbbbbbbbbsb
3-4 w: wwfjw
6-7 x: xxxxxxmx
7-15 g: ggggggrgggggggfggg
16-18 f: zffffffffffffffwfff
3-4 q: qcqn
3-4 k: kvzqk
4-18 z: wpclkbsxwbmbmkdpzzcm
1-8 z: zkzzzzzgzzzzz
7-16 x: xxxxxxxxxxxxxxjkxxx
3-6 t: xwcjztz
8-9 r: rdrprrtrs
1-7 v: dvvvvvcvvd
6-8 t: tttttkttt
1-5 w: xzwww
6-7 c: ctdjbwcc
3-4 t: ttnttt
9-10 q: qmcqqqsqqqvqqq
11-12 d: dpftdmdmdmld
7-8 j: tbjmbjlj
3-6 t: tttttqtt
6-8 t: tdttthbnqt
2-5 q: qqqqp
1-3 t: ttht
13-17 n: nnnnnnnnnnnnnnnndnn
4-6 j: ftkvjj
5-10 c: hvccfcsccb
7-11 v: vmqvqnnnvzglvvvv
5-8 k: kkkkkksckkk
1-12 z: rzzzzzzzzzzzzzzzvzz
17-18 t: tttttmtttmttttttpttt
16-17 z: xljjnngmjmhprcqzw
4-11 d: dtddbpddlhn
17-18 t: tptttttttttttttttbtt
9-12 w: wwwwwwwwwwwcw
3-4 z: zdzj
1-8 q: qlqqkqqhqtqhxqbbwcp
6-8 r: rkrrlrrmzrcnnrk
13-17 b: dbsbbbbbbbsbmkbbb
5-16 q: gqnvqwwgqshmtrdbplfb
7-9 c: mcvccccczc
10-11 p: pppxppppppc
1-6 v: vvvvvmvvvvv
5-6 s: ssssks
6-14 r: prgrbvrjrgrkrrr
2-11 c: qbnxcvxgldcvdd
11-15 d: ddddddddddsddddd
13-14 w: rwwwwwwwwwwwwsw
12-15 t: ttttttttttttttt
5-8 g: skjgxsjpgvsgr
5-11 g: ggddglggxgqgg
2-4 c: cccc
2-3 h: rvdg
9-13 r: rrrrrrrrsrrrjrrr
2-7 f: dflmgzsdftgkgc
1-5 f: jffffffnfcff
3-4 c: cccrqc
2-7 m: kblcghm
3-4 r: rscrnbbpfkr
2-3 d: wdtqpd
5-6 q: qqqpqnqq
13-15 d: ddddsdddddddddjd
3-4 c: cmcw
2-7 q: qqqqqqjqqqqbqfqq
11-14 x: txxxxpxdxxkxqcv
10-11 b: bbbbbbbbbkbb
7-11 p: ppppppppppmpv
5-6 r: dnxrcvrrr
1-4 d: rdddddd
5-9 f: lxgfvffdf
8-16 k: vmfksjkwkrkkkhkkvknk
15-16 v: vvvvvqvvvvvvvvgv
2-5 p: xpctr
11-15 w: wfwwwwwkwwwwwpr
11-13 x: xxxxxxxlxrfxxs
18-19 b: bbbbbbbbbbqbbbbbbbb
2-4 l: fgwl
8-11 m: xmjnmmmmnmh
4-6 g: lgvpksgq
5-7 t: jtgtvttjlfhpljtzzstd
7-11 p: mjcgvcmxgqpntxkpb
2-3 r: rrgrrnr
6-7 r: rrrrrcr
4-14 d: dddjdddddddddpdddd
5-7 q: qqqqkqqqq
1-4 t: qttqt
4-10 f: hbfjbzrfgvffq
16-17 j: wjjwjwpsjjdvfjnhv
3-4 v: vvtwv
5-6 s: ssdswspdss
1-2 r: rnrrmskrr
4-7 h: rqxbjjhsfh
4-9 l: llllllllhl
4-6 w: sgtwwmcpwd
4-11 l: fjdllznlllmdnll
4-5 k: kkklk
4-6 s: sszrssssssss
12-14 w: wwwwwwwwwwwvwww
2-4 b: vnzb
7-18 g: ggggggggggggggggggg
1-13 s: srjdvvpqnrsnnkzfj
14-15 g: bmhbclmqcgtqxgg
8-12 g: gggfhxgglgzb
3-5 c: scrkcshctccmhm
7-12 q: qklqqqhqvxqqqqw
1-6 m: mlmxzwkmm
3-16 r: rswggrrrrczxfpjt
14-16 l: llldlblllqllllns
2-5 w: wwwwmw
7-9 r: rrrhrprrr
2-3 j: zjmdfcth
3-8 w: xwgwwwwww
1-5 l: plllllll
2-4 b: fbqp
2-3 p: jwpmp
3-4 c: kscm
2-5 b: mbpbnfkvh
4-15 m: qrswmmmgmvmfqtmrrn
12-15 r: rxrrrrrdrhpfrrrrcrrr
10-13 j: jjljjjjjjnjjjjj
8-20 w: gjccptmwtrwxjtskrdfp
11-14 j: jjjjjxjjjjgjjk
1-4 g: gggzzgg
4-8 q: wqqqqblsmsk
1-11 h: lhhhfhhhhbvhhtjwrbh
4-8 x: xlxqxxtxxxxx
13-14 x: xxxxsxxxxxxxqxxx
12-16 b: bxvbbbqbbbbfzbblb
1-4 j: jzbd
5-6 q: qqqqwqkkqqq
2-5 x: xxxxgx
8-10 n: nnnnnnnnnhn
5-10 m: mmmmrmmmmmmmm
2-3 c: qwcz
3-5 n: cckvz
18-19 q: qqqqqqlqtqqqqqqqjqv
5-13 k: kkpkkkkkkkkklkkk
5-10 q: jfjgqllmqzv
15-17 l: llllllllllllllhll
4-10 b: pgqbfrsnvbhzfmtbtw
1-4 c: mccc
6-16 f: fffffpfffffffcfffff
4-9 j: qjbjlcsgljtbvv
11-12 z: dstqbtxxvdchsg
3-8 d: jvdpnvqs
2-3 n: nfvnnnn
6-12 r: zdbfdrvtmpkrjkr
1-15 k: kbdckwtkfhvrbjk
6-8 v: fvhsvgcv
2-3 p: ppkppp
2-14 r: drclhnrdhtcbmnr
7-10 p: vchpmlpjfxbfnwsdxjr
1-3 v: lvvv
1-3 b: bbjbb
2-12 q: qmxbbbgqlscqvdtpq
7-9 l: lllllkllqlllclll
16-17 r: hrrrrrrrrrrrrrrrr
8-9 g: gggggggfg
6-8 v: zvqffmkv
9-12 t: tttttznttjtfrtsjxtd
5-12 q: bqhbltqnjlhqqhtkq
8-9 d: ddddddddkd
2-8 q: tvpqmrrq
13-16 q: qqqgmqqqqqsqmqqpqqqs
7-9 p: pppppplppp
4-6 h: hhxhlhhhxhp
6-8 g: gggggdggggg
4-5 j: jjjkjj
4-5 x: xxxfg
2-13 x: xxhrhxwbrgrdskghtkj
12-19 x: cxxxxxxxxxxhxxxxxxx
1-4 m: tmmmm
5-11 x: mgqnkjxxscxdxr
3-4 t: tttctt
4-13 b: bfkbfbbwbcbpvcbkdqww
5-7 d: dwddddqd
4-15 l: lvvlfclwbssvsdl
9-14 d: ndkfnddtdddfjpvdqt
8-9 s: ssssssssk
9-13 l: dlljknlsllbslhlml
4-5 n: lnnwn
8-12 v: rlvbqlwvfhvv
6-7 f: rcpfwfvffqfcpf
10-11 g: rnqgxbtnxqfzgggtn
8-11 d: ntdzzddkbdhcdddrgdld
5-6 s: xkmssxscvbpwj
1-3 r: rrmr
9-14 p: pvppppppppppppppp
11-15 t: vhftnbtmwpgbcvt
2-7 t: pmbwnrj
10-11 c: cccccccdcvcc
9-14 s: ssksssssssssslsss
2-5 t: ctrtqpn
4-6 t: mttjftttt
4-5 z: zfbzz
2-3 x: xwxlwstzmvvt
4-5 b: vbsbjwpbsbbb
3-4 x: cwxxlmdf
5-6 z: zzzqszzzzzz
1-4 c: ncczc
3-6 k: kkkkkkk
2-3 z: rjzkpxxdvzlzxjzz
8-10 z: fzjzszzdnzbzkzzfz
1-9 c: ccccxccjpccccc
3-12 j: jjjjjjjjjjjcj
10-14 l: llplllvbllllsp
8-12 r: hnrcrxfzrkcjcprrzjbr
17-20 q: qqkqqqqqqqqqqqqbqqqh
6-9 l: lllljlrlpxllllll
8-9 v: vzzmtwfgv
3-7 v: fqdbsshw
12-13 f: fwffnjfbfffzzqfxfffx
1-3 m: zjmdvjjg
5-7 r: nrswrlbw
8-11 c: crzfvzpcbcbchgxbln
9-17 g: ggggggzgwwjpggpgvgrk
6-9 k: hhkrvkkqfhqwbdb
10-16 q: mzzjqfmtkqwvgdfttj
11-13 m: mmmmmmmmmmtmm
1-2 j: jjhrrj
3-12 h: hhhhhhhhhhhhh
8-11 w: zwkrwznrppw
7-14 d: dpxjnddbvdbcllqr
5-8 c: ccccfcccccc
12-16 p: tnptbppgwxxpppjb
1-14 t: qktttttttttttttt
9-12 t: tttttcttgjtt
3-5 p: tcpdgwhrkxkzjjhvsgqp
13-14 k: kkkkkkkkkkkkklk
11-13 x: xxxxxxsxxxxxt
5-12 n: nxxnnznnnnmlnnn
12-14 h: hhlhhhhhhhzcnnhhhhkh
8-10 j: jbjbjmjvjj
6-9 c: ccccccccsc
5-12 j: jjjjjjjjjjjcj
1-2 f: fhffff
13-17 x: xnlxxxxsxxxxxxxxp
2-5 d: sddzn
2-4 q: qqqt
2-6 p: fmxfxnkp
9-11 k: nkdgncqkkgwjp
2-5 p: hpmgcfcmz
1-3 f: ffczf
5-9 r: rtrrprrrrrr
2-4 p: pnpprdn
9-11 l: ltllbllvllc
4-5 x: xxxmxxx
5-9 x: xxxxxxxxxx
16-20 b: hgcbhbbhbgbbdxhdgjwb
10-15 c: qcccpcccdcccccfccwcf
10-11 x: xndsgkwqpxb
15-17 f: wwbqxrffgfvffdmdffw
5-6 q: qqqhqvqqqq
3-4 h: hhhchc
7-9 x: xxxxxxxxgx
7-8 f: fmfflfgf
12-13 v: vvvvvvvvvvvcvvvv
3-7 g: gggbggsgg
1-5 w: wpswsggtw
3-5 h: hhhhkhhhhhdhw
6-7 w: wwwwwmwwwww
5-11 m: mfdmcwmlvpmfc
14-15 j: jjjjjjjjjjjjjjrjj
3-5 v: rvtvkdvqv
3-6 p: frppxpdpg
3-5 t: ttttrt
2-7 x: xxwxxkfxxxxxxxxxxgxr
6-8 k: kkkkkpkgkkkk
10-11 f: fffffpfffkfdf
11-12 g: gggghgnggflg
1-7 x: xxnxxxxkxx
3-4 h: rhhx
6-8 r: bcwrrrrrhrxmqgrhrzm
2-6 l: mpdlnnp
2-4 j: jbjjdhx
2-15 d: dfdddddddnddddfzddjd
5-12 h: gbngwvffshph
1-2 t: txcpth
14-15 f: ffffkfflfffffgf
8-9 b: bbbbbbpbj
5-6 f: zffhfz
8-15 j: qjjfrtjllqfjjcj
3-5 l: llxllll
10-15 z: tpdzhnzkzrtzrzzzrfrz
3-5 q: qqlqq
3-4 d: vmzddpm
8-11 c: cmvzlxtqxcvckxqm
2-13 r: drpppdsqsmvnlkjb
7-9 w: wwwwwwkww
3-6 s: svfspfnpzq
3-4 b: fqpbbbbzpgqf
2-4 s: smssm
8-9 q: qqqqqlqbq
4-7 s: stcssbw
15-16 k: kkkkkkkkkkkkkkkk
10-13 x: xxsxxzxzxxsxphxxxxx
4-5 p: drpsx
7-11 v: vvvvvvvvvvvvv
14-15 n: nnnnnnnnnpnnnbnn
5-8 k: blgkkkkc
12-16 g: ggggggggggvggggggg
1-8 c: cccccccdc
3-9 p: ppqppppppp
7-9 q: cxqqqbhqqzhjqv
1-12 m: mrkvwmmsjmkmw
2-4 s: xrrj
2-4 w: mbww
7-14 v: vvvvvvvvvvvvvbv
3-8 p: kppjprpxppb
4-10 n: znncndnnjncnrnkn
5-7 k: kktnkks
10-13 r: rrrrrrrrrrrrnr
1-6 k: kkkkkrvk
3-5 k: jhjzkbqsjwkxsvd
5-8 p: pcqpprckrp
2-5 f: fsjwf
6-9 l: jxhtplclr
4-13 x: gdxdcdmmxlfxxs
2-10 v: vvvrvvvvvhvvvvvvvv
11-12 v: wqnwrlvjsxvs
1-4 m: mfqm
3-5 d: bmddv
8-10 h: hbhhdhfchh
4-5 s: sssdb
2-3 l: lsll
10-11 k: kkkkdcpnkkgkk
6-8 r: vrrrrxrrrrr
3-4 s: gxsbfr
17-18 p: ptppppppbbpbprpcqpp
16-17 s: gpgwvvnjbdqpksnsd
5-10 f: gfkfzqflfzffvf
6-18 m: kxxfrxjmwmltdvxwmmb
5-6 d: ddntbd
11-15 b: bbbrbhbgbbltbbhb
6-7 r: krbrrrp
5-6 q: qqqqqkqqqqq
3-6 k: kfkmjt
8-10 d: drbwtrdshdbg
13-15 n: tqnprfnndhplcjn
2-4 w: wjwg
10-11 p: xprpnpvhppp
9-10 r: rrrrrrrrqrrr
2-8 w: wjwnwhwwwwwww
12-13 g: gggggggggggwggg
1-6 s: sssssss
1-9 k: xkkkkkkkkkkkkkv
2-4 c: ccccc
3-7 s: ftssfrm
12-13 k: kkkkkkkkbkksk
9-16 q: qqqmqbbqhzqwtlwqb
7-9 p: ppppppppdppp
4-6 b: pcvbvkhb
9-10 g: qmchkfggmgpqgxxgxq
2-9 t: sthtnttthtlsq
3-4 x: xxxx
8-14 s: ssssssssdssssssss
1-3 m: gmbmvbmqbxvm
10-15 s: sgwkdvnsswsszwrn
3-4 s: gmgs
5-11 f: fffffffffffffffff
7-9 v: vvfvsvzdhvv
4-8 l: lllllllpllllllllll
11-16 x: xxxplxxxxxpxxxxxxxxx
9-13 t: tdtftttjdtttc
9-13 g: rknsckngkvdxg
3-4 d: sdqwddmr
1-3 l: lljl
7-17 r: trhrpmrqswrmnrbrrhb
7-8 g: ghkxwgttgk
5-7 b: fbnbtbndb
6-7 v: vnxlvgv
1-6 t: txtkttg
2-13 n: ljnnnnlpsnscfnnnnnnf
4-11 b: bbbbbbbbbbfb
6-9 x: wxdkxxnnnx
2-4 w: wswww
5-13 j: jjsjjjjjjjjjkjjjj
1-4 f: fszhf
5-9 z: wzgfpzzzzjszfvfpwz
5-9 x: xxxxhxxxsx
15-17 b: bbbbbbbbbbbbbbkbqb
2-7 x: xvdmgxxwgxx
3-4 q: qqqq
6-7 m: mqmlltc
8-10 k: kkkfkhkkkpkkkk
2-6 n: cnxnts
1-6 s: gsssssssssscssss
1-9 n: bbvkmnkdn
2-5 p: nmlhpv
4-6 g: vnggdpgm
7-12 b: bbbbbbvwsbbbbbbbbbbx
2-3 b: lgbjjr
7-12 n: chqccgnwsznngz
4-6 v: nntkvvv
2-5 g: qkrjgkqgljh
1-5 f: rffffsfzxfjfzffff
15-16 z: zpzzzzzzzzzhzzkszz
3-4 l: lmflkl
7-8 f: fffvzxff
2-4 r: rrrgrrrr
12-14 w: tjwgwkkwwwwwwwwww
2-12 m: mzmkmmmmmhmmcmmmrmf
5-7 q: nfqbgqqqpqqgjq
1-4 r: ktpr
5-6 j: jjjgbj
9-13 d: ddpbdddwbbdmd
8-9 r: rphfrrrsrr
10-12 f: fffffffffffbffpff
5-12 b: xhbbcbbbbxtbbb
9-10 j: jjjjjjjjqjjj
3-4 q: qqqn
3-9 r: srrtqqprjmqgnp
2-3 c: gcqc
3-4 c: bclc
3-6 n: jnxhshghnnqncgncn
2-4 h: ckhh
9-12 t: tdjjqcdbtkbtmb
11-13 x: cxxkxbxktxxxkxxxpxxh
4-14 m: hjqmqjvqgjdjzsssdkm
6-12 r: rrrrrlrrrrrrrr
14-16 g: gngggggkfglzgggv
9-13 h: hvhhdzhhmhhhh
3-15 x: xxjxxxxxxxxxxxbxx
10-12 z: zzzzzzzzzpzzz
3-4 h: dnhv
13-14 g: gggggggggggggg
7-11 r: rrrrrrrrrrr
6-9 x: czxxlsxxx
3-5 h: hhchh
1-9 j: jjjjjgdjjjjjjjf
7-10 b: ctsbpxrvwbkbjklghnbn
10-11 g: gggggggggglg
1-7 x: xnpsxfm
9-10 q: xxxzqbpdqj
4-10 q: pqsqbqcvllfn
11-12 x: xxxkxxxxxxgxxxx
3-12 s: pstrsssntsssssbssj
9-12 s: wnsdfrtssllsfbsssccb
1-6 r: nrrrrmrc
11-13 k: kkskkkbkkkzkkk
4-5 h: hhhhshh
5-19 f: ffffffffffffffffffcf
3-4 z: zczzz
5-8 l: ghlllsllfw
3-9 g: ggpngglkkf
7-9 b: xwbbbhhbmgjhbbbhnbb
4-5 c: cjmgczcccpzqr
15-16 j: jqfqsnnvffpjjjqj
5-6 z: zzzztvws
3-7 t: tftxtvfzs
1-5 l: tlllll
5-18 n: nnnngnnnnnnnnnnnnnn
5-6 m: bchzqm
9-10 p: lmpsbqgzpxggltl
2-9 h: hqdpjwpxhg
4-6 n: nqbnbnknnzd
2-7 q: qbqqqvq
7-8 c: cccccclc
8-12 r: rrkrrrprvrcqnr
14-15 j: jkpjjnjjjwjjjjjjhjwj
7-9 s: stsstspsn
8-11 h: hhhhbhhhhjhhhh
5-6 d: dddtpdd"""

print(day2a(input))
print(day2b(input))
