import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int T = Integer.parseInt(br.readLine());
for(int i = 0; i < T; i++)
{
String str = br.readLine();
System.out.print(str.substring(0, 1));
System.out.print(str.substring(str.length() - 1, str.length()));
System.out.println();
}
}
}
charAt을 쓰면 되는데 왜 이렇게 했지;