Check if target word exists in matrix horizontally or vertically

easy