import java.io.*;
import java.util.StringTokenizer;
public class Main {
public static void main (String[] args) throws IOException {
BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
String line;
StringBuffer out=new StringBuffer();
while ((line = buffer.readLine()) != null) {
if(line.equals("#")){
break;
}
StringTokenizer st=new StringTokenizer(line);
int n=st.countTokens();
for(int i=0;i<n;i++){
if(i>0){
out.append(' ');
}
String nextToken=st.nextToken();
out.append(nextToken.charAt(nextToken.length()-1))
.append(nextToken.substring(1,nextToken.length()-1))
.append(nextToken.charAt(0));
}
out.append('\n');
}
System.out.print(out);
}
}
import java.util.StringTokenizer;
public class Main {
public static void main (String[] args) throws IOException {
BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
String line;
StringBuffer out=new StringBuffer();
while ((line = buffer.readLine()) != null) {
if(line.equals("#")){
break;
}
StringTokenizer st=new StringTokenizer(line);
int n=st.countTokens();
for(int i=0;i<n;i++){
if(i>0){
out.append(' ');
}
String nextToken=st.nextToken();
out.append(nextToken.charAt(nextToken.length()-1))
.append(nextToken.substring(1,nextToken.length()-1))
.append(nextToken.charAt(0));
}
out.append('\n');
}
System.out.print(out);
}
}