#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <vector>
#include <climits>
#include <string>
#include <algorithm>
#include <sstream>
using namespace std;
vector<string> split(string haystack, string needle) {
vector<string> result;
int startPos = 0;
int foundPos = haystack.find(needle, startPos);
while (foundPos != string::npos) {
int count = foundPos - startPos;
string token = haystack.substr(startPos, count);
if (!token.empty()) {
result.push_back(token);
}
startPos = foundPos + needle.length();
foundPos = haystack.find(needle, startPos);
}
string token = haystack.substr(startPos, haystack.length() - startPos);
if (!token.empty()) {
result.push_back(token);
}
return result;
}
string nameConvert(const string& name) {
const string DELIMITER = " ";
stringstream builder;
auto parts = split(name, DELIMITER);
for (auto part : parts) {
part[0] = toupper(part[0]);
transform(part.begin() + 1, part.end(), part.begin() + 1, ::tolower);
builder << part << DELIMITER;
}
return builder.str();
}
string dateConvert(const string& date) {
const string DELIMITER = "/";
stringstream builder;
auto parts = split(date, DELIMITER);
builder << setw(2) << setfill('0') << parts[0] << DELIMITER;
builder << setw(2) << setfill('0') << parts[1] << DELIMITER;
builder << parts[2];
return builder.str();
}
map<string, int> mp;
string email(string name) {
transform(name.begin(), name.end(), name.begin(), ::tolower);
stringstream builder;
auto parts = split(name, " ");
builder << parts.back();
for (int i = 0;i < parts.size() - 1;i++) {
builder << parts[i][0];
}
string tmp = builder.str();
mp[tmp]++;
if (mp[tmp] > 1) {
builder << mp[tmp];
}
builder << "@xyz.edu.vn";
return builder.str();
}
string password(string date) {
auto parts = split(date, "/");
stringstream builder;
for (auto part : parts) {
builder << stoi(part);
}
return builder.str();
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int query;cin >> query;
cin.ignore();
for (int i = 0;i < query;i++) {
string line;getline(cin, line);
auto parts = split(line, " ");
string dob = parts.back();
stringstream builder;
for (int i = 0;i < parts.size() - 1;i++) {
builder << parts[i] << " ";
}
string name = builder.str();
cout << email(name) << " " << password(dob) << endl;
}
return 0;
}