48 inputs and 48 ouputs with arduino mega

You might investigate an MCP23017 to support many interrupts. Datasheet states all sixteen I/O pins can detect interrupts and they can be joined to provide one signal to a controller.