#include<iostream> #include<algorithm> #include<map> using namespace std; string unique_string(string s) { sort(s.begin(), s.end()); s.erase(unique(s.begin(), s.end()), s.end()); return s; } int main() { string A; int n; while (cin >> A >> n) {...