// \\\\ \\ \\ \\ \\ \\ \\ \\ || || || || || || // // // // // // // ////
// \\\\ \\ \\ \\ \\ \\ \\ _ooOoo_ // // // // // // ////
// \\\\ \\ \\ \\ \\ \\ o8888888o // // // // // ////
// \\\\ \\ \\ \\ \\ 88" . "88 // // // // ////
// \\\\ \\ \\ \\ (| -_- |) // // // ////
// \\\\ \\ \\ O\ = /O // // ////
// \\\\ \\ ____/`---'\____ // ////
// \\\\ .' \\| |// `. ////
// //== / \\||| : |||// \ ==\\
// //== / _||||| -:- |||||- \ ==\\
// //== | | \\\ - /// | | ==\\
// //== | \_| ''\---/'' | | ==\\
// //== \ .-\__ `-` ___/-. / ==\\
// //== ___`. .' /--.--\ `. . ___ ==\\
// //== ."" '< `.___\_<|>_/___.' >' "". ==\\
// //== | | : `- \`.;`\ _ /`;.`/ - ` : | | \\\\
// //// \ \ `-. \_ __\ /__ _/ .-` / / \\\\
// //// ========`-.____`-.___\_____/___.-`____.-'======== \\\\
// //// `=---=' \\\\
// //// // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \\ \\\\
// //// // // 佛祖保佑 永无BUG 永不修改 \\ \\ \\\\
// //// // // // // // || || || || || || || || || || \\ \\ \\ \\ \\ \\\\
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <time.h>
#include <cstdio>
#include <math.h>
#include <vector>
#include <cstring>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define IOS ios::sync_with_stdio(0);
#define rep(i,x,y) for(int i=x;i<=y;i++)
#define per(i,x,y) for(int i=x;i>=y;i--)
#define SORT(x,y) sort(x+1,x+y+1)
#define UNQIUE(x,y) unqiue(x+1,x+y+1)
#define UPB(x,y,z) upper_bound(x+1,x+y+1,z)-x
#define LWB(x,y,z) lower_bound(x+1,x+y+1,z)-x
#define IT iterator
typedef long long ll;
const int N = 5e5 + 5;
const int INF = 0x3f3f3f3f;
const int ecnts = 1e-6;
ll read() {
ll s = 0, w = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-') w = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
s = s * 10 + c - '0';
c = getchar();
}
return s * w;
}
void print(ll x) {
if (x < 0) {
putchar('-');
x = -x;
}
if (x >= 10)
print(x / 10);
putchar(x % 10 + '0');
return;
}
inline int max(int x, int y)
{
if (x > y) return x;
else return y;
}
inline int min(int x, int y)
{
if (x < y) return x;
else return y;
}
inline void swap(int &x, int &y)
{
int t = x;
x = y;
y = t;
}
inline int pow(int x, int y)
{
int ans = 1;
while (y) {
if (y % 2) ans *= x;
x *= x;
y = y >> 1;
}
return ans;
}
void solve()
{
int n;
cin >> n;
rep(i, 1, n) {
string k;
getline(cin,k);
string p = k.substr(k.length() - 5);
cout << p << endl;
}
}
signed main() {
IOS;
int T = 1;
//cin >> T;
rep(fain, 1, T) {
solve();
}
}