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

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

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

b = A("b")
k = B("k")
m = C("m")
c = C("c")
h = A("h")
l = B("l")
n = A("n")

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

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

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

b = A("b")
k = B("k")
m = C("m")
c = C("c")
h = A("h")
l = B("l")
n = A("n")

b.q = c
k.y = l
k.t = l
k.s = c
m.z = c
c.z = m
h.q = m
l.y = k
l.t = k
l.s = m
n.q = c
assert l.y.t.t.txt == "k"