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

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

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

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

c.z = l
c.y = h
h.q = c
l.x = c
assert h.q.y.q.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.y: B = None
        self.txt = txt

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

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

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

c.z = l
c.y = h
h.q = c
l.x = c
assert h.q.y.q.txt == "c"