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

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

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

d = A("d")
e = B("e")
c = C("c")
m = B("m")
k = A("k")
j = B("j")
b = C("b")
a = A("a")
g = A("g")

d.x = m
e.r = j
e.o = g
c.o = k
m.r = e
m.o = a
k.x = m
j.r = m
j.o = k
b.o = d
a.x = m
g.x = m
assert a.x.r.r.o.x.r.o.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

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

d = A("d")
e = B("e")
c = C("c")
m = B("m")
k = A("k")
j = B("j")
b = C("b")
a = A("a")
g = A("g")

d.x = m
e.r = j
e.o = g
c.o = k
m.r = e
m.o = a
k.x = m
j.r = m
j.o = k
b.o = d
a.x = m
g.x = m
assert a.x.r.r.o.x.r.o.x.txt == "m"