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

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

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

m = A("m")
d = B("d")
j = C("j")
l = B("l")
n = C("n")
c = B("c")
e = A("e")
b = A("b")
h = C("h")

m.r = b
d.z = h
j.x = b
j.o = h
l.z = j
n.x = b
n.o = j
c.z = h
e.r = m
b.r = e
h.x = m
h.o = n
assert h.o.x.r.r.r.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

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

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

m = A("m")
d = B("d")
j = C("j")
l = B("l")
n = C("n")
c = B("c")
e = A("e")
b = A("b")
h = C("h")

m.r = b
d.z = h
j.x = b
j.o = h
l.z = j
n.x = b
n.o = j
c.z = h
e.r = m
b.r = e
h.x = m
h.o = n
assert h.o.x.r.r.r.r.r.r.r.txt == "e"