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

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

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

k = A("k")
g = B("g")
m = C("m")
j = A("j")
l = B("l")
i = A("i")
f = C("f")

k.o = l
g.s = i
g.r = j
m.t = l
m.s = g
j.o = l
l.s = j
l.r = j
i.o = g
f.t = l
f.s = l
assert k.o.r.o.r.o.r.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

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

k = A("k")
g = B("g")
m = C("m")
j = A("j")
l = B("l")
i = A("i")
f = C("f")

k.o = l
g.s = i
g.r = j
m.t = l
m.s = g
j.o = l
l.s = j
l.r = j
i.o = g
f.t = l
f.s = l
assert k.o.r.o.r.o.r.txt == "j"