General solution for the QND observables of a given system