What you should write depends on what you are trying to do, which has me puzzled. Perhaps if you spelt out what info you need to store, and what is to be done with it, then people could suggest ways of doing it.
As I see it, you want a data structure that comprises 27 cells, representing a 3 x 3 x 3 matrix. For that I would use bytes, and then have a number of subroutines to act on the matrix according to whatever you want to achieve. I would probably use pointers in the unaddressed memory area; to do this I would use three bytes as coordinates each with values 0,1,2 and then calculate the pointer value according to the cell I wanted to act upon. If x, y and z are the coordinates each taking the value 0,1, or 2, then the pointer would be base + x + (3 x y) + (9 x z). So if x,y,z were 000 then the address would be base + 0, if 1,1,1 then base + 13, and if 2,2,2 then base + 26 with all other values in there as well. I hope I got that right, it is late here.
Then any subroutine can read the three coords and find the value in the relevant cell and do something with it. And if you use the area I mean it won't use up any variables apart from the three coords.
If you really run out of space you can revert to bits but with an M2 or X2 I doubt you would and code that avoids bit fiddling is easier to debug.