Introduction to Algorithms