Completed day 19

This commit is contained in:
Gnarwhal 2020-12-19 00:39:13 -08:00
parent a7a8063922
commit 653c45bedf
2 changed files with 782 additions and 0 deletions

195
2020/days/day19.cpp Normal file
View file

@ -0,0 +1,195 @@
/*******************************************************************************
*
* Copyright (c) 2020 Gnarwhal
*
* -----------------------------------------------------------------------------
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files(the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*******************************************************************************/
#include <vector>
#include <unordered_map>
#include <string>
#include <iostream>
#include <fstream>
#include "../misc/types.hpp"
#include "../misc/print.hpp"
enum RuleType { Char, Sequence, Alternator };
struct Rule {
RuleType type;
char c;
std::vector<u64> list;
std::vector<std::vector<u64>> or_list;
explicit Rule(char c) noexcept : type(Char), c(c) {}
explicit Rule(std::vector<u64> && list) noexcept : type(Sequence), list(std::move(list)) {}
explicit Rule(std::vector<std::vector<u64>> && or_list) noexcept : type(Alternator), or_list(std::move(or_list)) {}
};
auto extract_numbers(const std::string & list) -> std::vector<u64> {
auto nums = std::vector<u64>();
auto end = usize(0);
auto start = usize(0);
while ((end = list.find(" ", ++end)) != std::string::npos) {
nums.push_back(std::stoll(list.substr(start, end - start)));
start = end + 1;
}
return std::move(nums);
}
auto matches(const std::string & string, usize & index, std::unordered_map<u64, Rule> & rules, u64 rule_id, bool sub) -> bool;
auto matches_list(const std::string & string, usize & index, std::unordered_map<u64, Rule> & rules, const std::vector<u64> & rule_ids, bool sub) -> bool {
auto local_index = index;
for (auto i = usize(0); i < rule_ids.size(); ++i) {
if (!matches(string, local_index, rules, rule_ids[i], true)) {
return false;
}
}
index = local_index;
return (sub || index == string.size());
}
auto matches(const std::string & string, usize & index, std::unordered_map<u64, Rule> & rules, u64 rule_id, bool sub) -> bool {
if (index >= string.size()) {
return false;
}
auto & rule = rules.find(rule_id)->second;
switch (rule.type) {
case Char: {
if (string[index] == rule.c) {
++index;
return (sub || index == string.size());
} else {
return false;
}
}
case Sequence: {
return matches_list(string, index, rules, rule.list, sub);
}
case Alternator: {
for (auto i = usize(0); i < rule.or_list.size(); ++i) {
auto local_index = index;
if (matches_list(string, local_index, rules, rule.or_list[i], sub)) {
index = local_index;
return true;
}
}
return false;
}
}
// むだmakes the compiler happy though
return false;
}
auto min_length(std::unordered_map<u64, Rule> & rules, u64 rule_id) -> usize;
auto min_length_list(std::unordered_map<u64, Rule> & rules, const std::vector<u64> & rule_ids) -> usize {
auto len = usize(0);
for (auto i = usize(0); i < rule_ids.size(); ++i) {
len += min_length(rules, rule_ids[i]);
}
return len;
}
auto min_length(std::unordered_map<u64, Rule> & rules, u64 rule_id) -> usize {
auto & rule = rules.find(rule_id)->second;
switch (rule.type) {
case Char: return 1;
case Sequence: return min_length_list(rules, rule.list);
case Alternator: {
auto min = min_length_list(rules, rule.or_list[0]);
for (auto i = usize(1); i < rule.or_list.size(); ++i) {
auto len = min_length_list(rules, rule.or_list[i]);
if (len < min) {
min = len;
}
}
return min;
}
}
// このもむだ!
return 0;
}
auto day19() -> void {
auto rules = std::unordered_map<u64, Rule>();
auto strings = std::vector<std::string>();
{
auto line = std::string();
auto file = std::ifstream("inputs/day19.input");
getline(file, line);
while (line != "") {
auto end = line.find(":");
auto id = std::stoll(line.substr(0, end));
if ((end = line.find("\"")) != std::string::npos) {
rules.insert_or_assign(id, Rule(line[end + 1]));
} else if (line.find("|") != std::string::npos) {
end = line.find(":") + 2;
line = line.substr(end, line.size() - end) + " |";
auto sequences = std::vector<std::vector<u64>>();
end = usize(0);
auto start = usize(0);
while ((end = line.find("|", ++end)) != std::string::npos) {
sequences.push_back(extract_numbers(line.substr(start, end - start)));
start = end + 2;
}
rules.insert_or_assign(id, Rule(std::move(sequences)));
} else {
end = line.find(":") + 2;
rules.insert_or_assign(id, Rule(extract_numbers(line.substr(end, line.size() - end) + ' ')));
}
getline(file, line);
}
while (getline(file, line)) {
strings.push_back(std::move(line));
}
}
auto successful = usize(0);
for (auto i = usize(0); i < strings.size(); ++i) {
auto index = usize(0);
successful += matches(strings[i], index, rules, 0, false);
}
print(successful);
successful = usize(0);
auto min_length42 = min_length(rules, 42);
auto min_length31 = min_length(rules, 31);
for (auto i = usize(0); i < strings.size(); ++i) {
auto unsuccessful = true;
auto base = min_length42 * 2 + min_length31;
auto list = std::vector<u64>{ 42, 42, 31 };
for (auto j = usize(0); unsuccessful && j * min_length42 + base <= strings[i].size(); ++j) {
auto copy = list;
for (auto k = usize(0); unsuccessful && k <= j; ++k) {
auto index = usize(0);
unsuccessful = !matches_list(strings[i], index, rules, copy, false);
copy.push_back(31);
}
list.insert(list.begin(), 42);
}
successful += !unsuccessful;
}
print(successful);
}

587
2020/inputs/day19.input Normal file
View file

@ -0,0 +1,587 @@
27: 116 44 | 127 69
19: 60 116 | 55 127
91: 127 13 | 116 127
11: 42 31
30: 80 116 | 100 127
53: 78 116 | 100 127
47: 116 129 | 127 76
21: 57 127 | 100 116
26: 86 116 | 28 127
86: 127 122 | 116 29
74: 127 39 | 116 105
41: 118 116 | 132 127
13: 116 | 127
115: 82 116 | 72 127
100: 116 116 | 116 127
5: 78 127 | 91 116
31: 101 127 | 121 116
134: 116 117
73: 123 116 | 62 127
69: 116 124 | 127 77
28: 71 116 | 66 127
14: 131 116 | 128 127
111: 127 59 | 116 117
6: 127 53 | 116 79
104: 26 116 | 65 127
61: 78 127 | 56 116
67: 127 30 | 116 130
32: 81 127 | 27 116
2: 116 117 | 127 72
128: 57 116 | 91 127
81: 127 96 | 116 51
38: 127 59 | 116 54
36: 22 127 | 107 116
35: 116 61 | 127 24
7: 116 100
18: 16 116 | 82 127
116: "a"
54: 116 116 | 127 116
84: 20 116 | 93 127
92: 38 127 | 111 116
64: 127 57 | 116 82
105: 116 43 | 127 110
44: 127 106 | 116 88
93: 33 116 | 56 127
82: 116 13 | 127 116
75: 2 127 | 9 116
65: 127 97 | 116 36
4: 5 127 | 98 116
1: 114 127 | 58 116
122: 54 127 | 59 116
70: 116 67 | 127 75
117: 127 127
68: 48 127 | 40 116
97: 127 95 | 116 113
132: 127 33 | 116 54
51: 23 127 | 30 116
119: 127 37 | 116 103
63: 57 127 | 59 116
34: 57 13
48: 116 73 | 127 47
23: 82 127 | 59 116
66: 127 82 | 116 78
95: 127 100 | 116 82
123: 117 116 | 82 127
24: 116 33
120: 49 127 | 99 116
103: 127 90 | 116 83
102: 72 13
58: 46 116 | 45 127
106: 56 127 | 117 116
85: 126 127 | 133 116
3: 74 116 | 85 127
20: 33 127 | 56 116
127: "b"
45: 116 102 | 127 18
126: 127 41 | 116 112
94: 116 87 | 127 21
114: 35 116 | 19 127
0: 8 11
99: 127 34 | 116 76
80: 116 127 | 127 116
50: 15 116 | 7 127
55: 127 91 | 116 59
90: 92 127 | 94 116
25: 57 116 | 54 127
124: 116 57 | 127 91
77: 78 116 | 78 127
56: 127 127 | 116 116
79: 116 59 | 127 57
12: 127 64 | 116 115
130: 17 127 | 33 116
8: 42
60: 116 72 | 127 59
113: 117 127 | 117 116
131: 16 127 | 56 116
46: 134 116 | 62 127
83: 6 127 | 50 116
33: 116 116
88: 116 57 | 127 54
118: 116 100 | 127 54
125: 100 116
121: 32 116 | 104 127
29: 127 17 | 116 57
101: 127 1 | 116 68
22: 116 117 | 127 100
43: 127 125 | 116 22
10: 29 127 | 63 116
112: 98 116 | 107 127
87: 80 127 | 57 116
129: 54 116 | 17 127
98: 116 80 | 127 117
57: 116 116 | 127 13
107: 127 72 | 116 59
40: 116 14 | 127 4
39: 12 116 | 84 127
133: 116 108 | 127 10
71: 127 56 | 116 54
76: 116 78 | 127 33
15: 127 59 | 116 78
42: 119 116 | 3 127
9: 127 72 | 116 100
72: 127 127 | 127 116
17: 13 13
16: 116 116 | 13 127
49: 53 127 | 25 116
62: 127 80 | 116 100
52: 72 116 | 33 127
37: 70 127 | 120 116
110: 89 127 | 87 116
96: 116 52 | 127 55
78: 116 127
108: 127 109 | 116 71
109: 116 59 | 127 16
59: 116 127 | 127 127
89: 57 127 | 33 116
babababababababaabbbbbabaaabbabbabbabbaa
abbbbbaababbbabbbbbaaaaaaaababbbaabbabab
bbaaaaababababbaaaaabbababbabaabaaaaaaabaaaaaaaa
aabaabbaaaaaabaaaaaaabaabaabbbbb
bbaababbaaabaabaababbaaaabaababbaabbbaababbaaabababaabab
bbabbabbabaabbaabbbbaabbbbaabbaa
baaaabbbabaaababbababbbbababbbbbaaaabaabaabbbbaa
aaaabbabbaaaabbbaabaaabbaaabbbbababaabab
bbbaabaabbaabaaaaaababbbbaaaabbaaabaaabbbbbbbbbbbababbab
aabaabbaaabaaaabbbbaababbaabababaabbbbab
bbaabbbbbaaabbbbbabbbbaaaabaabbaabbaabbabbababbb
aaabaabaabaaababbabbabbb
abbababbabbababbaaaaaaab
ababbaaaabbabbabaaaabbaaaabaaabbbaabbbbaabbbabbbbbbaabbabbabbaaaababaabaabbabbaa
abbababaabbbabbbaaababbbabaaababbaababaabaaaaaaaaabababbabababab
baabbbbabaababbabaababbbababbbaa
aaabaabbbbbbaaaabaaaaabaaaaaabaaaababbaaaaaabaab
babababbabaaabbabbbbbbbabaaaabbaabababaaaabbbaab
aabaabbaabbabaababaaaaaabbbababaaabbbbab
aabaaabbbaabaabbabaaabbabbababaabbbbabbb
abababbaaaabbababaaaaabaaaaaabbaabbbaabb
bbaaabbbbaababaabbbaabbbabbbababbbbabbaa
babaaaaabbbbbbabbabaaaba
baaababbaabbbabbaaaababbababbabbbbbbbbbbaabbbaaaaaababbbbbaabbbb
bbbbaaabbaaaabaabbbbbbbabaaababaabbbbaaa
bbabbabbbbabaabbaaaaabab
baaababbbbbbaababaabaabbbbbbaaaaaaaaababaabbbaabaabaaaba
baababaaaababaaaaaaabbbaabbbbbaabaaababaaabbabaaaaabbaaa
abbbbbbbaaabaababaaabbaa
bbbabaaaabbabbbaaaaabaaabbbaabaabbbaaabbbabaaaba
abaabbaabaaabbabaaaaaaaa
aaabaabbaabaaaabaaaabbaabbabbaab
bbaabaaaabbaabaaababaabb
bbabaaababbaaabbbbabbabbabaaaaabbaaaabbbabbababbabbbbaaa
abbaaabbababbabbbaaaabbababaabab
aabababababbbaabaaabababababaaaaaaabbaaabbabaaba
abaaaaabbbbbbaabbaaaabababaaaabb
bbbbabbabababbbbaaaaaaba
aaaaaabbbaabbbababbabbbabaaabbbbabbabbaa
bbbababbbababbbbbbbbbabaabbaabaababbaaaabbababbb
abbabbabaaaabaaabaaabbbaabbaabababbbaabaaaaaaaabbaaababa
abbbabbbabaababbaababaabbabababbaaaaabaababaabaabaabbabbbabbbbbb
bbbaabbbbbbababbaaabbabaabbbbababbaababbabbabaaababaabbb
bbaaaaababbaaaaaabababaaaababbbabaabababbabbbaaa
aabbbabbbbabaabbabbaabba
ababbababbbbaaaabbabbaab
abbaaaababbbbbabbaaabaaabbabbabbbabababbabaabbba
bababaabbbaabaabbaaabbaa
bbbaaaabbababaabbbababab
babaabbbbaaababaababaaabbbaabbab
bbbabaaabaaaababbaabaaabbababbbbbaabbaab
abbbbbbbaababaabaabababb
abbbabaabababababbaaaaabaaabbabb
baaabbabbbbaababbbaabbba
bbbbaabababaabbabaabbbaaaababbab
abbaaaaaaabaaabbbaaabbababbaaaaa
aaaabbabaababbababbbbaababbbbaaa
abbbbbbbbbbaaabbbabbabbb
abaaababbababbbbbabaaaabbabbaabbaaaababb
bbaabbbabbbabbbbabaabbbb
babbaababbbbbbabaababaaabbaabaababaaaaba
bbbaaaabbbbbaaabbaabbaba
ababbaaabbbbbaabbbaabbbbbaabbbbb
baabbbabbaababbbbbbabbbb
abbaabaaaaaabbabbaaabbabababbaaaababbbbbaaaababb
bbbbbaabbbbaaabbbbabaaba
bababbaaaababaaabbbabbba
bbbbaabbaababaabababbbaa
bbbaaaaaabaabbabaabaabaa
bbbaaabbbbabbabbaababbbb
aabababababbaabaabbaaaaaabbabbabaabbabab
babbbabbaaababbbbbabaabbabaaaabb
aababaaabbbbbaaabaabbabb
bbbbbaaabaaabbababbaaaaaabaabaaa
bbaaaaaababaaabbaabbaaaa
baababbbaaaabbaaabaabbba
aababaaaabababaaaaaabbabababbbbb
bbaababaabbababbbbbbbaaaabbbaabbabbbaaaa
bababbbbaababaaabaabbbbb
bbaaaaaababaaaababababaaabaabbba
bbbaaaaaabbaabaaabbaabaaabbabaaababbbabaaabbaaababaaabbb
aabbbbbbbbbaaaaaaabbabbb
bbabaababbbaabaabaaaabbaabbabbbbbabaabbabbbababaaababbababbabbbabbabbbbabbabbbababbabbaababbaaaa
abaaababbabbbaabbabaabbaabaaabbaabbbaaabbaabbaabbbaaaabb
aabaabbbbbbaababbabbaababbbbbbaa
baabaaabbbbbbaaaabbbbbabaabbbaba
bbbbbbbabbaababbabababab
aaabaaabbbbbbababaaababbbbbbbbabaaababababbbbaaaabaababaaabaabababbaabba
abababaabbaabbbbaabbaaaa
bababbbbbbbbbaabbaaabbaa
abbbbbbaaabbbaaaaabbabab
baaaababbbbaaabbaaaaaabbababaabb
abbbbbabbbabaabbbabbaabb
aababbbabbbbaabbaababbaa
bbbbaabbbbaaaabaaabbabaa
abbaaaabbbaaabaabbbababbbbbbbbbabbbaababbaababbabababbabbbbabbbabbaaabba
aaabbabaababaaaaabababbaabbababbbbbbbababbbbbabb
abbbbbababbbaaabaabbaaba
abbbbbbaaabbaaabaabbbbbaaabbaababaaaaaaa
ababaaaaaaababbbaaabaaaa
babbbbaaabaaababbbbbbbaa
abaaaaabbabaaaabbbbbbbaa
bbbaaaabbbbbabbababbbbbb
baabbaaaabaabbaabbbbbbaaabaaabababbbbabaabbbabbaaaababbaaaababbaaabbaaababbbbaba
bababbbabaaababbbabbbbaaaaaabbbaabbabaab
bbbbaabbbababbbbabbbabbbaabbbbba
aaabbbbaabbbaaabaababbaa
aaabbabababbbabbbbbbabbb
ababaaabbbababaabbbbbbbbbabaaabbabbbbbbbababaabb
abbbaaababbbbabaabbaaaaabbbabbaaaaabbabb
baabbbababbabaaabbbbbaaaaaabaabaabaaabbababbaaab
aabaabbabababbbbbbbababbbbabbbabbbaaabba
baaababbbbbaabaabaabbaba
abbbbabaabbbaaabbaabbbabbbbbaaabbbababab
babaaabbabaabbababaaabaa
abaaabbabaaaaaababaaabababaaaaabaabababb
abbbabbbaaababbbababaaaabbabababbbaabbab
aaaaabaaabbbbbbbbaaabbbaabbbbbbabbaabbabaaabbaab
bbbbbbbabbbaaabbaaabaabaababbabaabaaabaaabaaabbb
abbbbbbaabbabbbabbbbabbabbbbabbaaaaababb
bbbbbaaababbbaabaabbbbbbbbbbbbbbbababaaa
abbbbbbbbbbbbaabaabbaaba
abbaaaababbbbbaaabbabbbaaabaabbabbbbbbbababaabaa
abaaabababbbbabaabbaabbaaabababaaabbbabbabbababaabbbaaaaabaabbaaaaaaabba
bbaaabbbaabaaabbbbbaaaaababbabab
baaabaaabaababbabbabaaabaaabbabb
bbbbabbaabababaaabbbaaba
aabbbabbbaabbbbaaaabaaab
abaaabbabbaabaabaababababbabaaabbbbbbabbabbbbbbbbbbbbbbbababbbaabbabbaababbaaaba
bbbaabbbabbbaaabbbbbbabaabaaaaba
abbbbabababbbaabaaaababa
abbabbbaabbbbbbbaaabaabbbbbbaabaaabbabaabaabbbbb
babbbabbbbbaaabbabbaaaaaabbaaaabbbbbbbbb
bbbbaaaaabbabababbaaabbaabaaabbaababababbbbabbbabbaaaabaabbaabaaabbababb
abbabbbabaabbbabaaabbaab
bbaababbbaababaaaabaabab
bbbbababaaabababbbabbbbbbabababaabbaabaababbaaab
baaaababaaaaabbaaaabbbbbbbaaaaabbabbababaaaabbbb
baaaaaabbbaaaaabaaabbaabbabbbaaababbabba
abbbbabababbaabaababbbab
aaabaabaaaabaaabbbbababbaabbaaaabbbabbaa
aaaaaabbbbaaabaaaaaaabaabbbabababaabbaaa
abbbbbbbabbbbabaaabbabaa
bbaaaaabbaababbabbbaabba
abbbbababaaababbbbbbabab
abbababbababbbabaabbaabbaaaaaaaaaaabaaaa
bababbbbbbaaaaaaabbbabba
baaabbabbbbbabbabaabbaababbbaaaa
baabaaababbbaaabbaabaaabaababbbbababaaba
aaaabbaabbbaabbbbaabaabbbaabbaaa
baaabaaaabbbbbabaaabaababaabababbaaababa
abbabbabbaaaaaabbaaaabaababaaaababbbaabb
bbaaaaaaaababbbaaabaaaabbaaaabaababaabaa
baaaaaabaaaabbbaaabbaaba
aababababbbbbaaababababbbbaaaaaabbaaabba
bbbaaabbbabababbbababbaaaaabbaaa
baababaabababaabbbaaaabb
bbaababbaababbbaaababbbb
aaaaaabbaabbbbbbbbaaaaabbaaaababbbbababbbbaaaababababaaaabbbbaab
baaabbabababbabababaabbaabbaabaaabaababbbbabaaabbabbbaaaaaababbabbabbbabaabbbaab
abbbaaabbababbbbabbbabba
aababaababbbbbbbabbababbbbbbbaba
abbbabbbbabaaabbbbaabbbbababbaaaaabababaabbaababbbbbbbaababbaabbbbbbbbaaabababbb
bbbaaaaaaababbabbbbbabaabaabbbabaabbbbbbbababbbb
baababbabaaabaaababaaabbbaabaabbbbbaaabbbabbabaaababaaba
aaabaaababbaaaaaaaabababbabaaaba
abaaababaabaaaabaaaabbbb
bbbaabaababbaababaaaaabaaaabaababbababab
bbbbbabaabbaaaaabaaaaabaabaabaab
baaaabaaabbabaabbbbbbbbb
bbaaaababbbbbbabbaababbaabababbabbbbaaaaabbbbbaababaabaabbbaaabaaaaababbababbbaaaaababba
bbbababbababbabbbabbbaabaabaaabbbababaabaabbaaaa
bbbbaabaaaaabbabbababbab
baabaaabbabaaaaababaaaba
abbbabaabaabbbbaabaababa
abbbbbaabbbbbbabbbbbaabbbaaababbabbabaaaaabababb
bbbbaaabaaababbbaaaaabab
bbbaaaaabbbbaabababbbbba
abbabbbaabbbabbbbaaaabbababbaaababbbaaaa
aaabbaaababbbabaaaababaa
ababaabbabaaaaaaaaaaababbbaaabbbbbbababababbabbaaaaabaabaaabbbab
baababaabbbaabaabababbaabaabbbbabbbbbabb
abbbabbbaabababaabbbaabb
baaaabbaaababaabaabaaabbabbabaabbaaabbbababbbaaa
baababaababbbbaabbaaaaaabbbbaaababaabbaaabaaaaabaaaaabbb
abbabbbbbaaabbbbabbbaaaa
abbbbabababaaaaaabbaaaaababbbbbabbbbabab
bbbaaabbabaaaaaaaaaaaabbababaaaabbaaaaabaabbaaaa
bbbbaabbbababbaaabababbabaaaabaabaabaaaa
baaababbabbaaaababbabbaa
abaaaaabbbabaaabaabaaaabaaabababbbaaababaaababaabbaaabab
bbbaaaabbababbbbababbbba
baaababbbababaababbbbabb
aaabbbbbabbabaababbaaaabbaabbaba
baabaabbaaababababbbbbaababababbaabaabbaaabaaababbabbbaabaabbabbaabbabba
baaaabbbbabaaaaabbabaaabaabaaaabbbaaaababbaaaabaabaabaaaabaabaaaabbbabbaaabbaaab
bababbbbbbbbaabbabbababbbabaaaaabbbabaab
baaabbababaabbababaabaab
abbaaabbbbbbaabaabbbbababababbbbababaaba
bbbbaabaabbaabbaabaabbbb
baababbbbbbbbababaaaabbbaaaaabbb
aaaabbabbabbaababbabaaababbaabab
aababbbabaabaabbbbbaabaabbabbbaa
abaabbaabbaabbbbaabbaabb
bbbaaaabaaabbbbabaaabaaabbababbbaabbbaab
abaabbaaaaabaabbbbbbbababbbbbababbbaabbbbbaabbba
baababbbbbbababbaaaaabaababbbbba
abbabaaaaababaabababbaaabbaaabbabaaabbaa
abaaabbaabababaaaabaaabbbababbbbbaabbbbbaabbabbaababbbab
bbaabbbbbbabbbbaabbaabaababbbaababbababbbbabbabaabbaabbbaabbaaaa
baabababababaaaaaabbabba
babababbbbaaabaaabaabbbb
abbabaaaaaaaabaaabaaabbababbbbaabababaabaaaaaaaaaabbbbbaaaaabababbababba
bbabbabbabaaabbaaabbabab
aabbbbbbbbaababbbaaabaaaaabaaaba
bbaababbabbaaaabababaaba
bbabaabbbaabbbbbabaaabaabbbbbbaa
bbbabaaabbbaaaababababbaabaaababbbbaaabbbbbabbaabbabaababaaababa
abababaaaababbbababbabab
bbbbbabaabbababbbbabbabbaabbaaaa
babbaabababaaaabbbaabbaa
bbbaabbbbababababbabbaab
bbbaabaaabaaaaaaababbbbbbbaaaabababbabababbaaabbababaabbabbaabaabbbabbaa
bbbbabbabababbaaaaaabaab
babbbaabbababbabaaababbbaaababbaaabbaabb
abaabbababaababbabbbaaabbbbbabbb
bbbabaaabaaaabbababbbabbabbbabbbabbbbbbabbabbaaa
bbabaabbaaabaabaabbabbabaabaaabbaabbbbaa
bbababaabaaaaaabbabbbbaabbaabaabaabbbababbaabbba
abbaaabbbaaabbbbbabbbabbaaabbbaa
bbbabaaaabaaabbaabbabbaa
abbbbbbaabbabaaaababbbab
abbbabbbaaaabaaaabbbbbaababaaaababbabbbaaabbbbba
abbabaabbaaabaaaaabaabbbaaabaabaabbbaaaa
bbbaaaaaabbaaaaabaabbbaaabaaaababaaaaabb
baabbbbabababbbabababaabbaaabbabaabbbbaa
aabaabbbabbabbabbabbabba
babbbabbbbbaabbbaababbbabbabaaababbaabab
bbbaabaaaaaabaaaabbbabaababaaaaababaabaaaabbaaabbabbabbb
aabaabbbbaabababaaaaabbb
baababaabaaabbabbaaabbaa
abababbabaabbbabbbaaaabaabbaabbabbbbabbb
abbbabbbabbababbbababaaa
bbabbbbaabababbaabbabaabababbaaaaabbabaabbbbabab
aaabbabababbbabbaabbbbab
bbaabababbaaabbbaabbbbab
baaabbaababbbbbaaabaaabaabaabbbababbaaab
bababbbbbbbbaabbbbbbabaa
bbaaaabaaaaabaaaabbababaaabbbaab
aaabbaabaaaabbabbbaaabababbbbababbbaababbbaaaabbabaabbab
ababbaabaabbbbbbbabaaaabaaaaaaab
baaabbbaaaabbabaababbbab
bbbbaababaabaaababbbabbbbaaabbbbaaaaaabbbabaabaaaabbabbb
bababbaaaaaabaaabbbaababaaaaabbaabbaaaaaaabaaaaaabaabbbbbabbbbababbbaabb
aaabbababaaabbbbabbaaaaaaaaabbbaaaabbbaababaabbb
aabaaaabaaaabbbabababababbbbaabaaabaaaaa
aaaabbaaabbabbbaabbabaaababababbabbabaaaabbaabbb
aaaabbbbbbababbaabbbaabbbabbbbaaabbaaabbbababbaabbbababbabbbababbaababbbaababbaaaaababbb
babababbbbabaabbbbaaaabb
abaabbabaaabaababbababaabbabaaababbbbaaa
aaaaabaabaaaabaaaaabbaaa
baaabbbaabbaaabbaababaabbbaaaaaaabbbaabb
babaaaabbaabbbabbbbabaab
baaababbbbbbbaaaaaaaabaaababbbabaaaaabab
bbbaabaabaabbbabbbaabbba
aaaaabbbabaabbbaabaaabbaabbbbbabaaaabaabaabbabbbbbbabbbbbbabbbbaaaaabbaa
abaaaaabbabbaababbaababbaaaaabaaababbaaaaaaabbbbbaabbaaa
babaaaabbbaababbbaabbaaa
babbbbaaabaabbaababaaaabbbababaabbbbbbaababaabaa
baaaaaababababaabbbabbba
bbaaabaabbaaabaaaabaabbaabbaabbaaabbaaaa
aaabbbbbaaabaababbbbbaababbbaaababbabbbabbbbbbbbaaaababbabbbaaba
bbaabaabbbbbbaaabababbab
baaabbbbbbbbbabbbaaaaabb
aabbbabbbaaaabbbaabaaabbaaabaabaabaabbbbbaabaaba
abbaaaaabbbbbaaaaaaabbbababbabba
bababbbaababbabaababaaab
bababbaaabbbbbabbbabbaab
bbabaabbaaabaababbbbabbaaaaabbbaaaabbbbabbabbaab
bbabaabbbaaaabbaabbbbbaababbbbaaaabbbbba
babaaaabbababababbaaaabababbaaab
bbbbaabaaabababaaabbbbbababbbababaaaaaabbbaabbabaaabbbaa
baaabbbbabbababaabababbaabbaabababaabaaa
bbabaaabaababababaaaababbbbbbbababbaababaabbbaab
bbbbbabbaababaaabbbbbababbbababa
bbbabaaaaabbbbbbbaabbaab
bbbbabbaabbbbbababaaabbaaaabbbbbbbbbbabababbaabb
abbabbabbbbbabbabaaaaaaa
bbaabaabbabbbbaabbbabbaababbbababbababbbbbbbabbb
abababbbaaaababbbabbaabb
bbabaabbaaaaabaaabbabaabaabaaaba
bbabbbbaaaabababbbabbbbb
bbaaaaabaaabbabaabbaabaaaabbbabaaabaaaaa
baaaaaabaabaaabbbaabababaaabaaababaaabbbbabaabaabaabbaba
bbbababbbaababbabaaaabaabbbaabaaabababbbababbbbb
bbaababbbabbbabbaababbbababababbbbbaaaba
baaabababbabbabbabbbbabbbabaaabaaabbaabababbbbbbbaabbbaa
ababaaaabbbbbabaabaabbabababbabbaabbabba
bbabbabbbabababaaabbaaba
baaabbbaabababbbbaabbabbaabbaabbbababbbaabbaaabbbabaaabbaaabbbab
aabababaabaaabbaaaaababb
babaabbaaaabbbbbaaababaa
aaabaaababbbbabbabbabaababababab
abaaaaaabbabbabbababbaabbabaabaa
aaaaabaaabababaabbababba
babbaabbaaaabababbabbbbbaaaababa
bbaabbbbbababaababaabbbb
bbaaaaaabbbbaabbbbbaaabbaaabbaabaababbbb
bbabbbbaaababbaaabbabbaaabbbaabaaababbab
bababababaaaabaaabababbb
baaabbbaaabaaaaaaabbbbba
baabbbbabbbaabaaaaaabbababbaaaaabbaaabbb
babaabbabbbbbabaabaaaaaabbbabbaaabaabbba
babababbbabbbbaaabbaaaababaaaaabababbaaaaaabbbabababbbabababbbbbbbbbabbb
aabaabbbaaabbbbaabbabbabbabbababbaaaaabb
baaabaaabaaabbabaaaabbabbbaabbaaabaabaaa
aaabaababbbbbbabaabbbbbbaaaabaab
aabbabbbbbbbbbbbababbbabaaabbbaa
bbbaabbbababbababbbbaaabbababbbabbababba
bbabbbbabaaabaaababababbaabbaaaa
abbabbabbaaababbbbbaaaba
baaabbbabbbbabbabbbbabbb
abbbabaabbaabaaabbbaaaababbababbabbbaaaaaabbaabb
bbbbbaaabababbbabbbaaaba
baaaababbbaababbaababbaa
baabbbbabbaabaaaaabbaaba
abbbabaabbbaababbbabaaabaaaabbaabbabaaba
bbababaabbbabaaabababbbbabaaabbb
ababbaaaabbbbbabbbabaaba
bbbbaabbbbbaaaabbbaabbbaaaabbabb
bbbbbbababbabbbbabbaaaababbbbbbbbbabbbbb
abbaababbbaabbaaaaabbbababaababaabaaabaaaaaababb
baaabaaabbbbabbababababaaabaaabbabbaaabbbaabbabb
baabbbaaaaaaabbaabaaaaababbabbabbbaaabab
ababababbabbaabbbabbabbbbabaaaaaaaaabbbb
baababbabbbaabbbabaaabbaabbbabba
bbaabbbbbbaababbbabababbbbbaaabbabbaaaaabbbbbbbbbbbbabaaabbbaaaa
baaaaabaaabaaaabaaabbbbaababbaabbbbbbabaaababbaa
abaabbaaabaababbbbaabbaa
baaabaaabbaaaaaababaabab
bbbbaaabbabababbbbaaabba
aaaaaabbababbabbabbabababbabaabbaabbabbbbbbaaababbabbaba
bbbbbabababaaaabaabbaaaa
baaaabaaaaabbbbbbababbbbbbbaabbbbaaabaabababbbaa
bbaaaabaabbbbbaabbaaabaaaababaaabaaaabaababbaaab
bbaabbbbbbaaaabaaaabbbbbbbaaabaaababbaaaabbaaaabaabaaabaabbbabbaababbbab
bbbbaababaaabaaaaabbbbba
aaabbbbaabababaabbaababaaaabababaaaaaaaa
bbaabaabaaaabbbabababbaaabbbbbaabbabaabaaaabbbab
aaabaaabbbaabaaabaaabbababaabbabbbabbbaa
abbabaababbabbbabbbaaabbbbbababa
aaabbbbbaabaabbababbbbba
baaaabaabbaababbababbbba
bbbbbbabbabbbaaaababababaababbbaaababbbabaabbbbaabaabbaaabbbbaaa
abbabaabbaaabaaabaabbaaabaabbaaababbbbbbbbbbaabaabaabbab
abbbbbbbbbbababaaaabaaaaabaababaababbbbababbaaaa
ababbabababbbaababbabbbaabbabbbbbbabbaaa
baaaabaababaabbabbaaaaaabbbaaaaaabaaabababaaaabbbabbaaaa
abbbbbaababbbaababbaaabbbbaaabbbbbababab
aabaabbaabbbbbababaabaaaabbaaabaabbaaababbbbabaaabbababbabbbbabaabbbaaaaaaabaabb
babbaababababababbaabbba
abbabaabaababbbababaabaa
bbaabaaabaabababbaabababbaaababbbbbaaaabbabbbbbbababbbbaababbbbbbabbbaba
aaabaaabbbaaabbbbbaaabaabaaaababbbabbbabababababbbbabbaa
bbbbbbaaabbbabaababaabaaababbbabaaabbbbababaaaabbbbbbbbabaaababbbaaabaabbbbbabbaaaabaaba
aaabbbbabbbaabaaabbaabaabaaababaaabbbaab
abbaaabbbbbbaabbbaababaababbbbba
bbaaaaabbbbabaaabaaabaab
bbbaaaaababababbbaaabbbbbaababbabaabaaaaababbbbabbababba
ababbaaabbbbbbbaabaaaaaababaabaaabaaabaa
baababbbbaaababbaabbbbba
babbabbbabbabbaabababbbbaaaabbbbbbbbaaabbabbaabaaababbab
bbabbabbabbaaaabbaabbbaaaaabaaababbbbbabbabbabba
bbbbaabababababbbabaabab
abbbbabbababbaabaabbabab
aaabaabbbbbabaaaaababbab
baaaaabaabaaabbabbaabbbbbaaabbaa
bbbbaabaababbababbbabbab
aababaaabbbbbbbabbbababbbabbaabbabaaabbb
aabbbaaaaaaaabaabaaaaaabaabbbbbbaabababb
aaaaaabbbaabaabbaabbabba
aaaaabbaaaabaabbabaababa
aaabababbbbaaabbabbaaabbbbbaaaaababaaaaaababbababbbabaab
abaababbabaabbabbbbaababbbaabbba
aababaaabbbbbabaabbabbbbabbabbbbaaabbbbbabbababbbbaaabababaaaaba
aaabaaababbababbaaaabbbabbbbabaaaabbbaba
bbababbbaaabbaababaabbbbaaaabbbabaaaabbababbabbbabbaaaaaabbaaabababaabba
aaaabbaabaaaaaabbababbbbaababbaa
abaababbaaabbbbabbaabaabbbbbaabaababbbabbabbaaab
aababbbbaabbaaaabbaabbabababbabaaabaaaaabaaaabbbabababab
babbbabbbbbaaabbaabbabbb
bbaaaaaaaabbbabbaabaabbabbbbaaaabbababba
bababbbbbbbaabbbbbbabbab
bbbaaabbabbbbbaaababbbbb
abbbbbbbbbbbbaabaabbabbabbbbbabbaabbabbaabaabaababbbabbbbbbbbbaabbbabaaaabbbaaba
aabbbbbbaaaaaabbbbbbaaababbbbbabbbaabaaabbbbbbbb
bbaabababaababbbaaabbbab
bbbbbabbbbbbaabababbabbb
bbabbabbabababbaaaababbbbaabababbaabbabb
aabbbbbbbaaabbabaaabbbbbbaabbaaaaaaabbbb
bababbbaababbaabbaaababbabbabbbbbababbbaaaabbbbbabbabbaa
aabbbaaaaaaabaaaaababaaababbbbabaabaabab
abbaabaaaaabaaabbbaaabbbaaabbbbbbbbbbbaaaabbaabaababbbbb
bbbabbbababababaabbabbbaaaaaabaaaaaaabaabbbbaabaaabbabaabaababbbaaaaabaaabbbbbbbbaaabbaabaaaabaa
baabaaabbaabbbaaaaabbbaa
babaaaaaabbabbababbbabba
bbbbaabbbbabbbbaaaabbbbb
aabaaabbbabbbabbbbabaabbaabbbabbbbaaabaabababaaabbabbaaaabbaabbaaabababb
bababababbbbaaaabaabbbbaaababbaaaaabbaab
bababaabbaaaababaaaaaaba
abbababbbabbaabababbbbaaaabababaaaabababbababaaa
abbaabaaabbabaabbbaaabbbbaaabbbb
abaaababbbaababbabbbabbbaaababaa
bababbbbabbbbababbbabbab
baaabbbababbbabbaabbbbba
aaaabbbabbaaabaaaabbbaaabbababba
bbbaaaabbbabbbbaabbbabba
abaaaaabbbbaaaaabbabaaabaabbabbababbbbbb
aaaaabbaaaabababbbbaaaba
ababaaaaabaabbabbbbaababbbbbbbaababbaaaa
babbbabbabaaaaaabababababaabaababbbabbaa
aaaaaabbaaabaababbaaabba
baabbbaabbababaabbbbaaaabbaabaabbabaabbbaaaababa
abbabaaabaaaabbbaaaaabbb
aababbbaabbbbbabbbababaabbbaabababbbabaaabbbbaab
abbabaaababbabaaabbabbabbaabbbab
bbabbbbaabbbbbabbbaabaabaaabaababbbabaababaaabbbabbaabba
abaabbbabaabbabababaaabbbaabbabaaaababaababbbaabaababbab
abababbabbbababbabbbbabbbabaabab
aaaaabbabaaabaaaabaaabaa
aaabbbbabbabbabbababaaaaaaaaabaabaabbbbb
ababbababbbbabbabbbaaaaabbabbaba
abbbbbbababbbbaaabbabaabaabababb
bbaaabaaaaaabaababaabbabababbaaabbaababbaaabaababbaababbaabababbbaaababaaabbaaabbbbbbaaa
aaaabaaabaababbbabbbbbbaabaabaaa
bbaabaabaababaaaabbbabaabbaabbab
abbbabaaaaaaaabbaababbbaabaaaaababaaaaaabbaabbaa
abbabbababbbabbbabbbabbbaaaabaaabbaabbaaabbbabbabbbbbbbb
bababaabaababbbaabbababaababaaab
bbaaabaaababbaaabbaabbba
aabaabbaabaaaaaabbababbb
ababbbbbbbbbbabbbabbaabbbbbaabababababbabbaabbabaaaabbbbabbbbaab
abaabbaaabbababaabbbaabb
ababaaaaabbabbbababaaaba
baabaabbabaabbaabaababaaabbbbbbbaababaaabaaabbaaabaabbbb
baaabbabaaabbbbbaababaabbabaaabaaaababaa
bbaaabbbbbbbaaabaaaaaaba
aabaaaababbaaaabbbbbbabbaabbaaba
abaabbababbaaaabbababbbaaaabbabb
bbaaababbaabbbababaaaaabbababaabaaaabbaaababbaaaaaaaababaaabbaab
aababbbabababbbaabbbabba