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

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

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

h.t = b
c.q = h
c.z = b
e.t = b
b.q = h
b.z = c
assert c.z.z.q.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

h.t = b
c.q = h
c.z = b
e.t = b
b.q = h
b.z = c
assert c.z.z.q.t.txt == "b"