There are `4` possible cases.
Case - 1 : When `X` invites all three men and `Y` invites all three ladies.
Total number of ways in this case `= C(3,3)*C(3,3) = 1*1 = 1`
Case - 2 : When `X` invites two men and one lady and `Y` invites one men and two ladies.
Total number of ways in this case `= C(3,2)*C(4,1)*C(4,1)*C(3,2) = 3*4*4*3 = 144`
Case - 3 : When `X` invites one man and two ladies and `Y` invites one lady and two men.
Total number of ways in this case `= C(3,1)*C(4,2)*C(3,1)*C(4,2) = 3*6*3*6 = 324`
Case - 4 : When `X` invites all three ladies and `Y` invites all three men.
Total number of ways in this case `= C(4,3)*C(4,3) = 4*4 = 16`
Therefore, total number of required ways `= 1+144+324+16 = 485.`