Given two measured spaces $(X,\mu)$ and $(Y,\nu)$ , and a third space Z,given two functions u(x,z) and v(x,z), we study the problem of finding twomaps $s:X\rightarrow Z$ and $t:Y\rightarrow Z$ such that the images $s(\mu)$ and $t(\nu)$ coincide, and the integral $\int_{X}u(x,s(x))d\mu-\int_{Y}v(y,t(y))d\nu$ is maximal. We give condition on u and v for whichthere is a unique solution.