// General imports import java.util.*; import java.io.*; import java.math.*; public class SkewerScurvyEasy { static char[][] input; static int[][] ids; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); for (int i = 0; i < a; i++) { int count = 1; int h = sc.nextInt(); int w = sc.nextInt(); input = new char[h][w]; ids = new int[h][w]; for (int k = 0; k < input.length; k++) { String s = sc.next(); for (int j = 0; j < input[0].length; j++) { input[k][j] = s.charAt(j); ids[k][j] = count; count++; } } boolean hitPillar = false; ArrayList safeNorth = new ArrayList<>(); for (int j = 0; j < w; j++) { hitPillar = false; for (int k = 0; k < h; k++) { if (hitPillar && input[k][j] != '#') { safeNorth.add(ids[k][j]); } if (input[k][j] == '#') { hitPillar = true; } } } String out = "Testcase " + i + " NORTH:"; Collections.sort(safeNorth); for (int n = 0; n < safeNorth.size(); n++) { out = out + " " + safeNorth.get(n); } System.out.println(out); hitPillar = false; ArrayList safeEast = new ArrayList<>(); for (int k = 0; k < h; k++) { hitPillar = false; for (int j = w - 1; j >= 0; j--) { if (hitPillar && input[k][j] != '#') { safeEast.add(ids[k][j]); } if (input[k][j] == '#') { hitPillar = true; } } } out = "Testcase " + i + " EAST :"; Collections.sort(safeEast); for (int n = 0; n < safeEast.size(); n++) { out = out + " " + safeEast.get(n); } System.out.println(out); hitPillar = false; ArrayList safeSouth = new ArrayList<>(); for (int j = 0; j < w; j++) { hitPillar = false; for (int k = h - 1; k >= 0; k--) { if (hitPillar && input[k][j] != '#') { safeSouth.add(ids[k][j]); } if (input[k][j] == '#') { hitPillar = true; } } } out = "Testcase " + i + " SOUTH:"; Collections.sort(safeSouth); for (int n = 0; n < safeSouth.size(); n++) { out = out + " " + safeSouth.get(n); } System.out.println(out); hitPillar = false; ArrayList safeWest = new ArrayList<>(); for (int k = 0; k < h; k++) { hitPillar = false; for (int j = 0; j < w; j++) { if (hitPillar && input[k][j] != '#') { safeWest.add(ids[k][j]); } if (input[k][j] == '#') { hitPillar = true; } } } out = "Testcase " + i + " WEST :"; Collections.sort(safeWest); for (int n = 0; n < safeWest.size(); n++) { out = out + " " + safeWest.get(n); } System.out.println(out); } sc.close(); } }