Constraints of the Kadomtsev-Petviashvili hierarchy