ON bit fixed by recursive

def B(N,M,p=""):
 if N<1:print p
 if M<N:B(N-1,M,p+"0")
 if M:B(N-1,M-1,p+"1")
B(*map(int,raw_input().split()))

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return top