#include #include #include #include using namespace std; class filesystem_t { private: set dirs, files; public: void add(string path) { for(int i = 1; i < path.length(); i++) { if(path[i] == '/') { dirs.insert(path.substr(0, i)); } } files.insert(path); } public: string normalize(string path) { string cwd = ""; int k = 0; for(int i = 1; i < path.length(); i++) { if(path[i] == '/') { string dst = path.substr(k, i - k); k = i; if(dst == "/..") { if(cwd.empty()) return ""; cwd = cwd.substr(0, cwd.rfind('/')); } else if(dst != "/.") { cwd += dst; if(dirs.find(cwd) == dirs.end()) return ""; } } } string base = path.substr(k); if(base == "/..") { if(cwd.empty()) return ""; cwd = cwd.substr(0, cwd.rfind('/')); } if(base != "/" && base != "/." && base != "/..") { if(files.find(cwd + base) != files.end()) return cwd + base; cwd += base; } if(files.find(cwd + "/index.html") == files.end()) return ""; return cwd + "/index.html"; } }; int main(void) { ifstream cin("D.txt"); int n, m; while(cin >> n >> m) { filesystem_t fs; for(int i = 0; i < n; i++) { string path; cin >> path; fs.add(path); } for(int i = 0; i < m; i++) { string q1, q2; cin >> q1 >> q2; q1 = fs.normalize(q1); q2 = fs.normalize(q2); if(!q1.empty() && !q2.empty()) { cout << (q1 == q2 ? "yes" : "no") << endl; } else { cout << "not found" << endl; } } } }