I have used two input nand gate instead of three input and four input. Because three input and four input nand gate(7410 and 7420) is not simulated.