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

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

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

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

c.r = h
h.s = n
m.q = a
m.z = k
k.s = n
a.q = m
a.z = k
n.r = k
assert h.s.r.s.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

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

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

c.r = h
h.s = n
m.q = a
m.z = k
k.s = n
a.q = m
a.z = k
n.r = k
assert h.s.r.s.txt == "n"