def read_data(): H, W = map(int, input().split()) Ss = [input().rstrip() for h in range(H)] return H, W, Ss def solve(H, W, Ss): x1, y1, x2, y2 = get_star_pos(H, W, Ss) x3, y3 = put_star(H, W, x1, y1, x2, y2) print_stars(H, W, x1, y1, x2, y2, x3, y3) def get_star_pos(H, W, Ss): xys = [] for y, S in enumerate(Ss): for x, c in enumerate(S): if c == '*': xys.append(x) xys.append(y) return xys def print_stars(H, W, x1, y1, x2, y2, x3, y3): star_pos = [(x1, y1), (x2, y2), (x3, y3)] for h in range(H): row = [] for w in range(W): if (w, h) in star_pos: row.append('*') else: row.append('-') print(''.join(row)) def put_star(H, W, x1, y1, x2, y2): for x in range(W): for y in range(H): if is_valid(x1, y1, x2, y2, x, y): return x, y raise RuntimeError("Couldn't find star pos.") def is_valid(x1, y1, x2, y2, x3, y3): x1 = x1 - x3 x2 = x2 - x3 y1 = y1 - y3 y2 = y2 - y3 return x1 * y2 != x2 * y1 H, W, Ss = read_data() solve(H, W, Ss)