Try thinking 3 dimensional. Arrange your magnets in a cube fashion and select them on 3 axis, x,y, & z. You could use 3, 4x16 decoder chips off the parallel port to get the selects. Wire first chip to bits 0-3, second chip to bits 4-7, and third chip to control register bits. Each magnet driver would require a 3 input "and" gate wired to decoder outputs with a unique x,y,z drive to select it. You can select more than 400 (16^3) in this fashion but you cannot do multiple relays without some extra hardware to lock/hold them up.
Dialtone