def classify_itypes_by_hand(itype_nodes, weapons_txt):
    """
    Reads Weapons.txt and classifies item types into 3 groups:
    1-hand only, 2-hand only, and mixed.
    Weapons that can be both 1- and 2-hand are classified as 2-hand weapons.
    Item types not used by weapons are ignored.

    Returns:
        A tuple of 3 sets containing itype codes, in order:
        - Item types that contain only 1-hand weapons
        - Item types that contain only 2-hand weapons
        - Item types that have both 1- and 2-hand weapons
    """

    one_handers = set()
    two_handers = set()

    for weapon in weapons_txt:
        code = weapon["code"]
        if not code:
            continue

        if weapon["2handed"]:
            target_group = two_handers
        else:
            target_group = one_handers

        itype_codes = []
        if weapon["type"]:
            itype_codes += itype_nodes[weapon["type"]].ancestor_codes()
        if weapon["type2"]:
            itype_codes += itype_nodes[weapon["type2"]].ancestor_codes()

        target_group.update(itype_codes)

    mixed_types = one_handers & two_handers
    one_handers -= mixed_types
    two_handers -= mixed_types

    return one_handers, two_handers, mixed_types