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

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

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

c.x = e
h.r = c
b.r = c
e.x = i
i.x = c
assert c.x.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

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

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

c.x = e
h.r = c
b.r = c
e.x = i
i.x = c
assert c.x.x.x.x.x.txt == "i"