/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.regex.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		List<String> strs = Arrays.asList("D99","M00.0","M01.6","J98.3","T05.0","M96.81","D68.20", "9D.0","6G","7H.","M96.811","J234.82","G687.1","GU87.11");
		for (String str : strs)
			test(str);

	}
	public static void test(final String myString){
	   final String rule = "[A-Z]\\d{2}\\.?\\d{0,2}";
	   final Pattern pattern = Pattern.compile(rule);
	   final Matcher matcher = pattern.matcher(myString);
	
	   if(!matcher.matches()){
	         System.out.println("Failure, the String" + myString + " is not valid!");
	   } else  {
	   		System.out.println("Success, the String" + myString + " is valid!");
	   }
	}
}