import java.util.regex.*;
class T {
public static void main
(String[] args
) { String s
= "Match foo and bar and baz"; Pattern p = Pattern.compile("Match (.*) and (.*) and (.*)");
Matcher m = p.matcher(s);
while (m.find()) {
System.
out.
println(m.
group(1)); }
}
}
aW1wb3J0IGphdmEudXRpbC5yZWdleC4qOwoKY2xhc3MgVCB7CiAgICBwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmdbXSBhcmdzKSB7CiAgICAgICAgU3RyaW5nIHMgPSAiTWF0Y2ggZm9vIGFuZCBiYXIgYW5kIGJheiI7CiAgICAgICAgUGF0dGVybiBwID0gUGF0dGVybi5jb21waWxlKCJNYXRjaCAoLiopIGFuZCAoLiopIGFuZCAoLiopIik7CiAgICAgICAgTWF0Y2hlciBtID0gcC5tYXRjaGVyKHMpOwogICAgICAgIHdoaWxlIChtLmZpbmQoKSkgewogICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4obS5ncm91cCgxKSk7CiAgICAgICAgfQogICAgfQp9Cg==