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

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

j = A("j")
d = B("d")
b = A("b")
c = B("c")

j.t = b
d.w = j
d.z = j
b.t = j
c.w = j
c.z = j
assert c.w.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

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

j = A("j")
d = B("d")
b = A("b")
c = B("c")

j.t = b
d.w = j
d.z = j
b.t = j
c.w = j
c.z = j
assert c.w.t.t.t.txt == "b"