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

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

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

d = A("d")
i = B("i")
h = C("h")
j = C("j")
b = B("b")
c = C("c")
a = A("a")
l = A("l")
e = B("e")

d.x = j
d.p = j
i.u = e
i.s = e
i.r = j
h.o = a
h.r = d
j.o = d
j.r = l
b.u = i
b.s = i
b.r = c
c.o = d
c.r = d
a.x = h
a.p = j
l.x = j
l.p = h
e.u = b
e.s = b
e.r = j
assert d.x.r.x.o.p.r.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.p: C = None
        self.txt = txt

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

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

d = A("d")
i = B("i")
h = C("h")
j = C("j")
b = B("b")
c = C("c")
a = A("a")
l = A("l")
e = B("e")

d.x = j
d.p = j
i.u = e
i.s = e
i.r = j
h.o = a
h.r = d
j.o = d
j.r = l
b.u = i
b.s = i
b.r = c
c.o = d
c.r = d
a.x = h
a.p = j
l.x = j
l.p = h
e.u = b
e.s = b
e.r = j
assert d.x.r.x.o.p.r.txt == "l"