// using * saves typing import java.util.*; import java.io.*; public class Leutonian { public static void main(String[] args) { // in and out can be typed faster than input and output Scanner in = new Scanner(System.in); PrintStream out = System.out; // N is a constant but typing final takes time int N = in.nextInt(); // read the end of line in.nextLine(); // regular expressions final String VOWEL = "(a|e|o|u|y)"; final String CONSONANT = "(b|c|d|f|g|h|j|k|l|m|n|p|q|r|s|t|u|v|w|x|sh|ng|fn)"; final String CONSONANT_SH = "(b|c|d|f|g|h|j|k|l|m|n|p|q|r|s|t|u|v|w|x|ng|fn)"; final String PUNCTUATION = "(;|\\,|\\.|\\!|\\?)"; final String LEUTONIAN = "(sh" + CONSONANT_SH + "|" + CONSONANT + ")?(" + VOWEL + CONSONANT + ")*" + VOWEL + "?"; final String NOUN = ".*" + VOWEL; for (int n = 0; n < N; n++) { int nouns = 0; int nonNouns = 0; int other = 0; // read line word by word StringTokenizer line = new StringTokenizer(in.nextLine()); while (line.hasMoreTokens()) { String word = line.nextToken(); // remove all punctuation symbols word = word.replaceAll(PUNCTUATION, ""); if (word.matches(LEUTONIAN)) { if (word.matches(NOUN)) { nouns++; } else { nonNouns++; } } else { other++; } } out.printf("%d %d %d%n", nouns, nonNouns, other); } } }