I have been solving this problem http://codeforces.com/problemset/problem/26/D .I was unable to solve this on my own and looked for editorials here http://codeforces.com/blog/entry/610 but one thing i am unable to figure out is If suppose we have a favourable order i.e. order which will smoothly run so we can also permute the people having 10 euros and 20 euros amongst themselves in n! and m! ways.This will account for a different pattern .I am unable to guess why is that not taken into account and only different combinations are considered.

Well, whether is sequence "good" or "bad" depends only on placement of people who have

`10`

euros and`20`

euros. So we can divide all permutations of people inn!·m! classes. In each class all permutations are either "bad" or "good". So we can replace permutations with classes, because it doesn't affect freuqency of "bad" cases:(first is amount of "bad" permutations, divided by amount of all permutations, second is value calculated in editorial).

yeah got it. Thank you Kaban-5