def masks(N):
    """ all masks, i.e. lists of zeros and ones only, of length N """
    seqs = [ [] ]
    for i in range(N):
        new_seqs = [ ] 
        for s in seqs:
            new_seqs += [ [0] + s, [1] + s ]
        seqs = new_seqs
    return seqs