You would need to add a dismount routine that toggles ( overwrites the root from a sub-directory source that has a subdirectory in it of 0 and 1 with each folder contailing the config to write to root. )
This is probably way more work than it is worth btw as for the drive is usually dismounted by using windows to disconnect the thumb drive and just yanking it out will not make this toggle function and could corrupt the drive. So you will need to write a dismount program that dismounts only this device, but before it dismounts it overwrites the root before the disconnect is established. In such a program you would also need to keep a counter file so it knows to toggle between counter value 0 and 1 and so when the counter is at 1 it set it back to 0 for the next cycle and so it remains on 0, 1, 0, 1, 0, 1 alternation etc in which = 0 is to overwrite the root with that info, and = 1 is to overwrite the root with the other info.
*Is this a high school programming project? Just sounds like something that would make for interesting project to show off in a classroom where it otherwise is more work than it is worth.