#include <iostream>
#include <map>
#include <vector>
#include <sstream>
using namespace std;
int main() {
int n, q;
cin >> n >> q;
map<string, string> attributes;
vector<string> tagStack;
cin.ignore(); // Clear the newline character from the buffer
for (int i = 0; i < n; ++i) {
string line;
getline(cin, line);
stringstream ss(line);
char token;
ss >> token;
if (token == '<') {
// Opening tag
string tag, attribute, value;
ss >> tag;
if (tag[0] == '/') {
// Closing tag
tagStack.pop_back();
} else {
// Opening tag
tagStack.push_back((tag.find('>') != string::npos) ? tag.substr(0, tag.size() - 1) : tag);
while (ss >> attribute >> token >> value) {
if (value.back() == '>')
value.pop_back();
attributes[tagStack.back() + "~" + attribute] = value;
}
}
}
}
for (int i = 0; i < q; ++i) {
string query;
cin >> query;
if (attributes.find(query) != attributes.end()) {
cout << attributes[query] << endl;
} else {
cout << "Not Found!" << endl;
}
}
return 0;
}