import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; public class prog { public static void main(final String[] args) { Scanner scanner = new Scanner(System.in); String[] firstLine = scanner.nextLine().split(" "); int n = Integer.parseInt(firstLine[0]); int m = Integer.parseInt(firstLine[1]); int h = Integer.parseInt(firstLine[2]); String[] lines = new String[n]; String[] north = new String[h]; String[] west = new String[h]; int[][] boxes = new int[n][m]; for (int i = 0; i < n; i++) { lines[i] = scanner.nextLine().trim(); } for (int i = 0; i < h; i++) { north[i] = scanner.nextLine().trim(); } for (int i = 0; i < h; i++) { west[i] = scanner.nextLine().trim(); } for (int i = 0; i < m; i++) { if (north[h - 1].charAt(i) == '#') { for (int j = n - 1; j > -1; j--) { if (lines[j].charAt(i) == '#') { int count = 0; for (int k = h - 1; k > -1; k--) { if (north[k].charAt(i) == '#') count++; else break; } boxes[j][i] = count; break; } } } } for (int i = n - 1; i > -1; i--) { if (west[h - 1].charAt(i) == '#') { for (int j = m - 1; j > -1; j--) { if (lines[i].charAt(j) == '#') { int count = 0; for (int k = h - 1; k > -1; k--) { if (west[k].charAt(i) == '#') count++; else break; } if ( boxes[n - i - 1][j] > count) boxes[n - i - 1][j] = count; break; } } } } for(int i = 0 ; i < n; i++) { for(int j = 0 ; j < m; j++) { if (lines[i].charAt(j) == '.') { System.out.print('.'); } else { if (boxes[i][j] == 0) System.out.print('1'); else System.out.print(boxes[i][j]); } } System.out.println(); } } }