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

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

class C:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

j = A("j")
h = B("h")
l = C("l")
k = A("k")
m = A("m")

j.z = l
h.q = l
h.z = l
h.t = m
l.s = h
k.z = l
m.z = l
assert k.z.s.z.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

j = A("j")
h = B("h")
l = C("l")
k = A("k")
m = A("m")

j.z = l
h.q = l
h.z = l
h.t = m
l.s = h
k.z = l
m.z = l
assert k.z.s.z.s.q.txt == "l"