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

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

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

l = A("l")
h = B("h")
e = C("e")

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

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

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

l = A("l")
h = B("h")
e = C("e")

l.q = h
h.t = l
e.r = l
e.u = h
e.z = h
assert e.r.q.t.txt == "l"