```python
def longest_common_subsequence(X, Y, m, n):
    """
    Finds the longest common subsequence of two sequences X and Y.

    Args:
        X: The first sequence (e.g., a string).
        Y: The second sequence (e.g., a string).
        m: The length of sequence X.
        n: The length of sequence Y.

    Returns:
        A string representing the longest common subsequence.
    """
    # Create a DP table to store lengths of LCSs.
    # L[i][j] contains the length of LCS of X[0..i-1] and Y[0..j-1].
    L = [[0] * (n + 1) for _ in range(m + 1)]

    # Build the DP table L[][] in a bottom-up manner.
    for i in range(1, m + 1):
        for j in range(1, n + 1):
            if X[i - 1] == Y[j - 1]:
                L[i][j] = L[i - 1][j - 1] + 1
            else:
                L[i][j] = max(L[i - 1][j], L[i][j - 1])

    # Backtrack from the bottom-right corner of the DP table to construct the LCS.
    lcs_chars = []
    i, j = m, n
    while i > 0 and j > 0:
        # If the characters at the current positions in X and Y match,
        # they are part of the LCS.
        if X[i - 1] == Y[j - 1]:
            lcs_chars.append(X[i - 1])
            i -= 1
            j -= 1
        # If the characters do not match, move in the direction of the
        # larger value in the DP table, which corresponds to the longer
        # subsequence found so far.
        elif L[i - 1][j] > L[i][j - 1]:
            i -= 1
        else:
            j -= 1

    # The LCS is constructed in reverse order, so reverse the list of
    # characters and join them to form the final string.
    return "".join(reversed(lcs_chars))
```