from typing import List


def ds_find(s: List[int], x: int) -> int:
    """
    Find the subset containing x in s.
    """
    if s[x] != x:
        # Apply path compression
        s[x] = ds_find(s, s[x])
    return s[x]