Locally adjoint mappings and optimization of the first boundary value problem for hyperbolic type discrete and differential inclusions