#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
using namespace std;
#include <string>
#define SIZE 26
//TrieTree
struct TrieTree {
struct Node {
Node* children[SIZE];
bool isEndOfWord;
string translation;
};
Node* root;
Node* createNode() {
Node* node = new Node;
node->isEndOfWord = false;
for (int i = 0; i < SIZE; i++)
node->children[i] = NULL;
return node;
}
void insert(string word, string translation) {
Node* tmpNode = root;
for (int i = 0; i < word.length(); i++) {
int index = word[i] - 'a';
if (tmpNode->children[index] == NULL)
tmpNode->children[index] = createNode();
tmpNode = tmpNode->children[index];
}
tmpNode->isEndOfWord = true;
tmpNode->translation = translation;
}
string search(string key) {
Node* tmpNode = root;
for (int i = 0; i < key.length(); i++) {
int index = key[i] - 'a';
if (tmpNode->children[index] == NULL)
return "-";
tmpNode = tmpNode->children[index];
}
return tmpNode->translation;
}
};
int main() {
TrieTree T;
T.root = T.createNode();
/*T.insert("kot", "cat");
cout << T.search("kot");
T.insert("pies", "dog");
cout << T.search("pies");
T.insert("mysz", "mouse");
cout << T.search("mysz");
T.insert("piesek", "doggy");
cout << T.search("piesek");
T.insert("myszka", "mousy");
cout << T.search("myszka");
T.insert("kotek", "citty");
cout << T.search("kotek");*/
//while (true) {
// char command;
// string word, translation;
// scanf("%s", command);
// if (feof(stdin) != 0) break;
// if (command == '+') {
// cin >> word;
// cin >> translation;
// T.insert(word, translation);
// }
// if (command == '?') {
// cin >> word;
// cout << T.search(word);
// }
// if (command == '*') {
// }
//}
char command;
while (cin>>command) {
string word, translation;
if (command == '+') {
cin >> word;
cin >> translation;
T.insert(word, translation);
}
if (command == '?') {
cin >> word;
cout << T.search(word);
}
if (command == '*') {
}
}
}