#include <iostream>
#include <unordered_map>
#include <algorithm>
#include <string>
struct text
{
text() = default;
text(const std::string& txt) : data(txt) {}
std::string key() const { std::string k(data); std::sort(k.begin(), k.end()); return k; }
operator std::pair<std::string, std::string>() const { return std::make_pair(key(), data); }
std::string data;
};
std::istream& operator>>(std::istream& is, text& t)
{
return is >> t.data;
}
std::ostream& operator<<(std::ostream& os, const text& t)
{
return os << t.data;
}
std::string quoted(const text& t)
{
return std::string(1, '"') + t.data + '"';
}
int main()
{
using pair_type = std::pair<std::string, std::string> ;
std::unordered_map<std::string, std::string> map =
{
pair_type(text("scooby")), pair_type(text("shaggy")), pair_type(text("veronica")),
pair_type(text("fred")), pair_type(text("daphne")), pair_type(text("wilma")),
pair_type(text("betty")), pair_type(text("barney")), pair_type(text("dino")),
pair_type(text("bambam")), pair_type(text("pebbles")), pair_type(text("george"))
};
text t;
while (std::cin >> t)
{
auto it = map.find(t.key());
if (it != map.end())
std::cout << quoted(t) << " matches " << quoted(it->second) << '\n';
else
std::cout << quoted(t) << " matches nothing\n";
}
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dW5vcmRlcmVkX21hcD4KI2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPHN0cmluZz4KCnN0cnVjdCB0ZXh0CnsKICAgIHRleHQoKSA9IGRlZmF1bHQ7CiAgICB0ZXh0KGNvbnN0IHN0ZDo6c3RyaW5nJiB0eHQpIDogZGF0YSh0eHQpIHt9CgogICAgc3RkOjpzdHJpbmcga2V5KCkgY29uc3QgeyBzdGQ6OnN0cmluZyBrKGRhdGEpOyBzdGQ6OnNvcnQoay5iZWdpbigpLCBrLmVuZCgpKTsgcmV0dXJuIGs7IH0KCiAgICBvcGVyYXRvciBzdGQ6OnBhaXI8c3RkOjpzdHJpbmcsIHN0ZDo6c3RyaW5nPigpIGNvbnN0IHsgcmV0dXJuIHN0ZDo6bWFrZV9wYWlyKGtleSgpLCBkYXRhKTsgfQoKICAgIHN0Z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