// Solution to "Plaque"
//

import java.util.*;

class Cont {
  public int width,height;
  public String[][] cont;
  public int bottom[], top[];
  public Cont(int w, int h) {
    this.width = w; this.height = h;
    cont = new String[h][w];
    top = new int[w];
    bottom = new int[w];
    for (int i = 0; i < w; i++)
       top[i] = bottom[i] = 0;
  }
}
public class Plaque {
  public static Scanner in;
  public static int n, w, b; // #containers, container width, box height
  public static Cont[] container;

  public static void main(String[] args) {
    in = new Scanner(System.in);
    n = in.nextInt();
    w = in.nextInt();
    b = in.nextInt();
    while (n > 0) {
      container = new Cont[n];
      for (int i = 0; i < n; i++) {
        int h = in.nextInt();
        container[i] = new Cont(w,h);
        in.nextLine(); // flush end-of-line
        for (int j = 0; j < h; j++) {
          String line = in.nextLine();
          for (int k = 0; k < w; k++) {
            container[i].cont[j][k] = ""+line.charAt(k);
          }
        }
        for (int j = 0; j < w; j++) {
           int k = 0;
           while (k < h && container[i].cont[k][j].equals(".")) {
              container[i].top[j]++;
              k++;
           }
           k = container[i].height-1;
           while (k >= 0 && container[i].cont[k][j].equals(".")) {
              container[i].bottom[j]++;
              k--;
           }
        }
      }
      solve();
      n = in.nextInt();
      w = in.nextInt();
      b = in.nextInt();
    }
  }

  public static void solve() {
    int count = 1;
    int fullness = container[0].height;
    for (int i = 1; i < n; i++) {
       int diff = Integer.MAX_VALUE;
       for (int j = 0; j < w; j++) {
         int temp = container[i-1].top[j]+container[i].bottom[j];
         if (temp < diff)
           diff = temp;
       }
       if (fullness + container[i].height -diff <= b) {
         fullness += container[i].height-diff;
       }
       else {
         System.out.print(fullness+" ");
         fullness = container[i].height;
         count++;
       }
    }
    if (fullness > 0)
      System.out.println(fullness);
    else
      System.out.println();
  }
}
