
Beds and Desks
At Euler University, each of the
Some of the beds are in private rooms which a student occupies alone, while the others are in double rooms occupied by two students as roommates. Similarly, each desk is either a single desk for the sole use of one student, or a twin desk at which two students sit together as desk partners.
We represent the bed and desk sharing arrangements each by a list of pairs of student numbers. For example, with
The new chancellor of the university decides to change the organisation of beds and desks: a permutation
The students agree to this change, under the conditions that:
- Any two students currently sharing a room will still be roommates.
- Any two students currently sharing a desk will still be desk partners.
In the example above, there are only two ways to satisfy these conditions: either take no action (
With
With
and desk pairing
then among the
The downloadable text files beds.txt and desks.txt contain pairings for
1,3 2,4
With these pairings, find the number of permutations that satisfy the students' conditions. Give your answer modulo