While solving 2D Poisson's equation, how to apply floating boundary at two edges, and Dirichlet at other two?

I have a square, at left and right edge of it; I exactly know the boundary values (Dirichlet boundary). But at top and bottom edge, I want to let the potential to float. That means I don't imply any fixed boundary value rather I want the potential to take any value depending on the source term (i.e. right hand side of the Poisson's equation) as well as on the boundaries imposed at left and right edge.

How can I do that? More specifically, How would my matrix look to do it?

[Note: When I discretize the Poisson's equation in finite difference scheme, I get the matrix equation $Au$=$h^2$$f$$-$$B$, where $B$ serves for the Dirichlet boundaries. In the figure I show how it looks when I apply Dirichlet boundary at left and right edge. Then how to put floating boundary at top and bottom edge?] If you look at it from the discretized matrix perspective it's obvious: Total of $(m+1)(n+1)$ unknowns. $(m-1)(n-1)$ internal constraints enforcing the discretized form of the p.d.e. $2(m+1)$ Dirichlet constraints at the left and right boundaries. That leaves $2(n-1)$ unconstrained equations.