import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.regex.*;
class Ideone
{
{
Matcher m1 = Pattern.compile("(test1)(test2)?(test3)").matcher("test1test3");
if(m1.matches()) {
for(int g=1;g<=m1.groupCount();g++){
System.
out.
println("Group "+g
+": "+m1.
group(g
)); }
}
System.
out.
println("--------------"); Matcher m2 = Pattern.compile("(test1)()(test3)").matcher("test1test3");
if(m2.matches()) {
for(int g=1;g<=m2.groupCount();g++){
System.
out.
println("Group "+g
+": "+m2.
group(g
)); }
}
}
}
aW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CmltcG9ydCBqYXZhLnV0aWwucmVnZXguKjsKCmNsYXNzIElkZW9uZQp7CglwdWJsaWMgc3RhdGljIHZvaWQgbWFpbiAoU3RyaW5nW10gYXJncykgdGhyb3dzIGphdmEubGFuZy5FeGNlcHRpb24KCXsKCQlNYXRjaGVyIG0xID0gUGF0dGVybi5jb21waWxlKCIodGVzdDEpKHRlc3QyKT8odGVzdDMpIikubWF0Y2hlcigidGVzdDF0ZXN0MyIpOwoJCWlmKG0xLm1hdGNoZXMoKSkgewoJCQlmb3IoaW50IGc9MTtnPD1tMS5ncm91cENvdW50KCk7ZysrKXsKCQkJCVN5c3RlbS5vdXQucHJpbnRsbigiR3JvdXAgIitnKyI6ICIrbTEuZ3JvdXAoZykpOwoJCQl9CgkJfQoJCVN5c3RlbS5vdXQucHJpbnRsbigiLS0tLS0tLS0tLS0tLS0iKTsKCQlNYXRjaGVyIG0yID0gUGF0dGVybi5jb21waWxlKCIodGVzdDEpKCkodGVzdDMpIikubWF0Y2hlcigidGVzdDF0ZXN0MyIpOwoJCWlmKG0yLm1hdGNoZXMoKSkgewoJCQlmb3IoaW50IGc9MTtnPD1tMi5ncm91cENvdW50KCk7ZysrKXsKCQkJCVN5c3RlbS5vdXQucHJpbnRsbigiR3JvdXAgIitnKyI6ICIrbTIuZ3JvdXAoZykpOwoJCQl9CgkJfQoJfQp9