#include <iostream>
int order(std::string s) {
int n, len;
if (s.empty())
return 0;
n = order(s.substr(0, (len = s.length()) - 1)) * 26;
n += (int)((char)s[len - 1] - 'A' + 1);
return n;
}
class C {
int n;
public:
C(std::string s) : n(order(s)) {};
friend std::ostream &operator<<(std::ostream &stream, C c) {
stream << c.n;
return stream;
}
};
int main() {
std::string s;
s = "A"; std::cout << s << ':' << C(s) << std::endl;
s = "Z"; std::cout << s << ':' << C(s) << std::endl;
s = "AA"; std::cout << s << ':' << C(s) << std::endl;
s = "AZ"; std::cout << s << ':' << C(s) << std::endl;
s = "BA"; std::cout << s << ':' << C(s) << std::endl;
s = "ZZ"; std::cout << s << ':' << C(s) << std::endl;
s = "AAA"; std::cout << s << ':' << C(s) << std::endl;
return 0;
}
/* end */
I2luY2x1ZGUgPGlvc3RyZWFtPgppbnQgb3JkZXIoc3RkOjpzdHJpbmcgcykgewogIGludCBuLCBsZW47CiAgaWYgKHMuZW1wdHkoKSkKICAgIHJldHVybiAwOwogIG4gPSBvcmRlcihzLnN1YnN0cigwLCAobGVuID0gcy5sZW5ndGgoKSkgLSAxKSkgKiAyNjsKICBuICs9IChpbnQpKChjaGFyKXNbbGVuIC0gMV0gLSAnQScgKyAxKTsKICByZXR1cm4gbjsKfQoKY2xhc3MgQyB7CiAgaW50IG47CnB1YmxpYzoKICBDKHN0ZDo6c3RyaW5nIHMpIDogbihvcmRlcihzKSkge307CiAgZnJpZW5kIHN0ZDo6b3N0cmVhbSAmb3BlcmF0b3I8PChzdGQ6Om9zdHJlYW0gJnN0cmVhbSwgQyBjKSB7CiAgICBzdHJlYW0gPDwgYy5uOwogICAgcmV0dXJuIHN0cmVhbTsKICB9Cn07CgppbnQgbWFpbigpIHsKICBzdGQ6OnN0cmluZyBzOwogIHMgPSAiQSI7IHN0ZDo6Y291dCA8PCBzIDw8ICc6JyA8PCBDKHMpIDw8IHN0ZDo6ZW5kbDsKICBzID0gIloiOyBzdGQ6OmNvdXQgPDwgcyA8PCAnOicgPDw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