Given a binary string and m ordered pairs, how to find the lexicographically smallest string, such that the given m pairs must follow the same order?