Order of variables in matrix generated with varf with a [P1, P1, P0] fespace

Hello,
I have a closely related question. To make it more precise, assume we have

fespace UP(Th,[P1b,P1]);
fespace XY(Th,[P1,P1]);
varf UPxXY([u,p],[xh,yh]) = int(Th)(…); // for example …=uxh+uyh+pxh+pyh);
matrix M=UPxXY(UP,XY);

One can take UP instead of XY, or vice-versa. Motivated by problem specifics, I want to modify M, say its element M(i,j). For this, I need to know the dof corresponding to ith row and to jth column.

Wondering how to get this information directly or a posteriori. Definitely this depends on the algorithm the developers have used for computing M. I hope anyone can help.

Thank you!