how can i store which button was pressed last time among many...

You could store the button press in EEPROM. Take a look at the example sketches in the IDE under ">File >Examples >EEPROM"