import java.io.*; public class volley { public static void main(String [] args) throws Exception { BufferedReader in = new BufferedReader(new FileReader("ball.in")); int sets = Integer.parseInt(in.readLine()); for(int i = 0; i < sets; i++) { String [] inputs = in.readLine().split(" "); int a = Integer.parseInt(inputs[0]); int b = Integer.parseInt(inputs[1]); int num = Integer.parseInt(inputs[2]); boolean print_score = true; int current_serving_team; int current_hits; boolean serve_last_hit = false; boolean returning_serve = true; int receiving_team; int score[] = {0,0}; int last_hit_team; int hit; String hits[] = in.readLine().split(" "); hit = Integer.parseInt(hits[0]); int last_hit = hit; current_serving_team = get_team(hit,a); current_hits = 0; last_hit_team = get_team(hit,a); receiving_team = get_other_team(hit,a); for(int j = 1; j < num; j++) { if (hits[j].equals("X")) { int score_team = get_other_team(hit,a); if (current_serving_team == score_team) score[score_team-1]++; serve_last_hit = true; receiving_team = get_team(hit,a); current_hits = 0; current_serving_team = get_other_team(hit,a); } else if (hits[j].equals("A")) { int score_team = 2; if (current_serving_team == score_team) score[score_team-1]++; serve_last_hit = true; receiving_team = 1; current_hits = 0; current_serving_team = 2; } else if (hits[j].equals("B")) { int score_team = 1; if (current_serving_team == score_team) score[score_team-1]++; serve_last_hit = true; receiving_team = 2; current_hits = 0; current_serving_team = 1; } else { last_hit = hit; hit = Integer.parseInt(hits[j]); if (serve_last_hit) { returning_serve = true; if (get_team(hit,a) != current_serving_team) { if (current_serving_team == receiving_team) score[receiving_team-1]++; current_serving_team = receiving_team; serve_last_hit = true; current_hits = 0; print_score = false; j = num; } else { current_hits=0; serve_last_hit = false; receiving_team = get_other_team(hit,a); } } else if (returning_serve) { if (get_team(hit,a) != receiving_team) { int score_team = get_other_team(last_hit,a); if (current_serving_team == score_team) score[score_team-1]++; serve_last_hit = true; receiving_team = get_team(last_hit,a); current_hits = 0; current_serving_team = get_other_team(last_hit,a); } else { current_hits = 1; } returning_serve = false; } else { if (get_team(hit,a) == get_team(last_hit,a)) { current_hits++; if (current_hits >= 4 || last_hit == hit) { if (current_serving_team == get_other_team(hit,a)) score[get_other_team(hit,a)-1]++; serve_last_hit = true; current_hits = 0; current_serving_team = get_other_team(hit,a); } } else { current_hits = 1; } } } } System.out.println("Data Set " + (i+1) + ":"); if (print_score) System.out.println(score[0] + " " + score[1]); else System.out.println("Wrong Serve"); } } static int get_team(int num, int a) { if (num <= a) return 1; return 2; } static int get_other_team(int num, int a) { if (num <= a) return 2; return 1; } }