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

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

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

d = A("d")
j = B("j")
m = C("m")
k = C("k")
n = C("n")
e = B("e")

d.o = k
j.r = e
j.x = e
m.o = k
k.o = m
n.o = m
e.r = j
e.x = j
assert d.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

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

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

d = A("d")
j = B("j")
m = C("m")
k = C("k")
n = C("n")
e = B("e")

d.o = k
j.r = e
j.x = e
m.o = k
k.o = m
n.o = m
e.r = j
e.x = j
assert d.o.o.o.o.txt == "m"