class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.r: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

c = A("c")
i = B("i")
h = B("h")

c.s = h
c.r = h
i.y = c
h.y = c
assert i.y.r.y.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.r: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

c = A("c")
i = B("i")
h = B("h")

c.s = h
c.r = h
i.y = c
h.y = c
assert i.y.r.y.txt == "c"