import java.io.*;
import java.util.*;

public class Practice {
	public static void main(String[] args) {
		System.out.println(reverse("bagel"));
		
		File data = new File("reverse.txt");
		try {
			Scanner dataScan = new Scanner(data);
			String inputCountLine = dataScan.nextLine();
			Scanner s1 = new Scanner(inputCountLine);
			int inputCount = s1.nextInt();
			
			for(int i = 0; i < inputCount; i++) {
				System.out.println(reverse(dataScan.nextLine()));
			} 
			
		} catch (FileNotFoundException ryan) {
			System.out.println(ryan);
		}
	}
	
	// bagel
	// legab
	// Method that takes a String parameter and RETURNS a String
	public static String reverse(String word) {
		String reversed = "";
		for(int i = word.length() - 1; i >= 0; i--) {
			reversed += word.charAt(i);
		}
		return reversed;
	}
}
