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

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

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

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

i.s = b
m.o = b
m.t = i
k.r = i
h.o = m
h.t = i
b.o = m
b.t = i
n.r = i
a.r = i
assert i.s.o.o.t.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

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

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

i.s = b
m.o = b
m.t = i
k.r = i
h.o = m
h.t = i
b.o = m
b.t = i
n.r = i
a.r = i
assert i.s.o.o.t.s.txt == "b"