find the rectange in the matrix