#include <iostream>
#include <vector>
#include <string>
#include <fstream>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cout.tie(NULL);
cin.tie(NULL);
int t;
cin >> t;
vector<string>list(t);
for (int i = 0; i < t; i++) {
cin >> list[i];
}
for (int i = 0; i < t; i++) {
int first = 0, last = list[i].size() - 1;
cout << list[i].at(first) << list[i].at(last) << endl;
}
return 0;
}