// Arup Guha
// 2/9/2013
// Solution to 2010 MCPC Problem E: Mirror, Mirror on the Wall

import java.util.*;

public class e {

	public static void main(String[] args) {

		String mirror = "bdpq";
		String all = "iovwx";

		Scanner stdin = new Scanner(System.in);
		String s = stdin.next();

		// Process each case.
		while (!s.equals("#")) {

			// Build this backwards, looking for illegal letters.
			String ans = "";
			boolean flag = true;
			for (int i=s.length()-1; i>=0; i--) {
				if (s.charAt(i) == 'b')
					ans = ans + "d";
				else if (s.charAt(i) == 'd')
					ans = ans + "b";
				else if (s.charAt(i) == 'p')
					ans = ans + 'q';
				else if (s.charAt(i) == 'q')
					ans = ans + 'p';
				else if (in(s.charAt(i), all))
					ans = ans + s.charAt(i);
				else
					flag = false;
			}

			// Print result.
			if (flag)
				System.out.println(ans);
			else
				System.out.println("INVALID");
				
			// Get next case.
			s = stdin.next();
		}
	}

	public static boolean in(char c, String s) {
		for (int i=0; i<s.length(); i++)
			if (c == s.charAt(i)) return true;
		return false;
	}
}