This is actually an attempt of re-do of old submit which I mistakenly think that I can do better. However, I am wrong as I misunderstand the question. The algorithm is wrong from my new try. Just leave it as it is for a memo.