works for any L, too slow for L=36