Given an n x n grid of strings representing shapes, fill every empty cell so that each row and each column contains every shape exactly once. Empty cells are marked with ".". You are also given a list shapes of length n containing the allowed distinct shape names. Return the completed grid. You may assume the input always has a unique valid solution.
def complete_shape_grid(grid, shapes):