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

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

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

m = A("m")
n = B("n")
l = C("l")

m.q = l
n.p = l
n.t = l
n.z = m
l.p = m
l.y = m
l.z = n
assert l.z.t.z.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

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

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

m = A("m")
n = B("n")
l = C("l")

m.q = l
n.p = l
n.t = l
n.z = m
l.p = m
l.y = m
l.z = n
assert l.z.t.z.txt == "n"