
#include <iostream>
#include <list>
using namespace std;

list<string>::iterator search_word(list<string>& L, string word);

int main() {
   string p, w;
   list<string> L;
   cin >> p;
   while (cin >> w) L.push_back(w);
   list<string>::iterator it = search_word(L, p);
   if (it != L.end()) {
      it->replace(0, 0, "[");
      *it += "]";
   }
   it = L.begin();
   for (; it != L.end(); it++) {
      if (it != L.begin()) cout << ' ';
      cout << *it;
   }
   cout << endl;
}

