from typing import Union


def int_or_id(x: str) -> Union[int, str]:
    """
    Convert a string to int if possible

    Args:
        x: input string

    Returns:
        Union[int, str]: int represented by x, or x itself if parsing fails
    """
    try:
        return int(x)
    except ValueError:
        return x