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

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

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

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

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

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

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

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

e.z = c
c.z = l
c.u = e
c.q = e
l.x = e
l.t = e
assert l.x.z.q.txt == "e"