include[HTML_REMOVED]
using namespace std;
int main(){
int n; cin >> n; getchar();
string str;
getline(cin,str);
vector[HTML_REMOVED]v;
for(int i = 0;i < str.size();i){
int ans = 1;
if(str[i] == ‘/’){
while(i + ans < str.size() && (str[i + ans] != ‘/’))
ans;
v.push_back(str.substr(i + 1,ans - 1));
//cout << str.substr(i + 1,ans - 1) << “i的值:” << i << endl;
i += ans - 1;
}
}
for(int i = 0;i < n;i){
if(i != 0) cout << endl;
string s;
getline(cin,s);
if(s.empty() == 1) {cout << str; continue;}
bool fuck = false;
for(int k = 0;k < s.size();k)
if(s[k] != ‘/’) fuck = true;
if(fuck == false){cout << ‘/’; continue;}
deque[HTML_REMOVED]www;
for(int k = 0;k < s.size();k){
if(s[k] == ‘/’ && s[k+1] == ‘/’) continue;
if(s[k] == ‘/’){
if(k == s.size() - 1) break;
int ans = 1;
while(k + ans < s.size() && (s[k + ans] != ‘/’))
ans;
if(s.substr(k + 1,ans - 1) == “..” && www.empty() == 1){
k += ans - 1;
continue;
}
else if(s.substr(k + 1,ans - 1) == “..”)
www.pop_back();
else if(s.substr(k + 1,ans - 1) == “.”){
k += ans - 1;
continue;
}
else
www.push_back(s.substr(k + 1,ans - 1) );
k += ans - 1;
}
else{
int ans = 1;
while(s[k + ans] != ‘/’ && k + ans < s.size())
ans;
if(s.substr(k,ans) == “..” && www.empty() == 1){
k += ans - 1;
continue;
}
else if(s.substr(k,ans) == “.”){
k += ans - 1;
continue;
}
www.push_back(s.substr(k,ans));
k += ans - 1;
}
}
bool fack = true; //是根路径
if(s[0] != ‘/’) fack = false; //是相对路径
if(fack == true){
for(int k = 0;k < www.size();k){
cout << “/” << www[k];
}
if(www.size() == 0) cout << ‘/’;
continue;
}
else{
string _str = “”;
deque[HTML_REMOVED]xxx;
for(int k = 0;k < v.size();k)
xxx.push_back(v[k]);
for(int k = 0;k < s.size();k){
if(s[k] == ‘/’ && s[k+1] == ‘/’) continue;
if(s[k] == ‘/’){
if(k == s.size() - 1) break;
int ans = 1;
while(k + ans < s.size() && (s[k + ans] != ‘/’))
ans;
if(s.substr(k + 1,ans - 1) == “..”)
if(xxx.empty() != 1)
xxx.pop_back();
else
continue;
else if(s.substr(k + 1,ans - 1) == “.”){
k += ans - 1;
continue;
}
else
xxx.push_back(s.substr(k + 1,ans - 1) );
k += ans - 1;
}
else{
int ans = 1;
while(s[k + ans] != ‘/’ && k + ans < s.size())
ans;
if(s.substr(k,ans) == “..”){
if(xxx.empty() == 1){
k += ans - 1;
continue;
}
else{
xxx.pop_back();
k += ans - 1;
continue;
}
}
else if(s.substr(k,ans) == “.”){
k += ans - 1;
continue;
}
xxx.push_back(s.substr(k,ans));
k += ans - 1;
}
}
for(int k = 0;k < xxx.size();k++){
cout << “/” << xxx[k];
}
if(xxx.size() == 0) cout << “/”;
continue;
}
}
return 0;
}