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

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

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

l = A("l")
e = B("e")
h = C("h")
d = B("d")
k = B("k")
j = A("j")
c = B("c")
f = A("f")
n = C("n")

l.r = e
l.s = h
l.p = h
e.z = j
e.x = n
h.o = n
d.z = j
d.x = n
k.z = f
k.x = n
j.r = d
j.s = n
j.p = h
c.z = j
c.x = n
f.r = k
f.s = n
f.p = h
n.o = h
assert h.o.o.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.s: C = None
        self.p: C = None
        self.txt = txt

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

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

l = A("l")
e = B("e")
h = C("h")
d = B("d")
k = B("k")
j = A("j")
c = B("c")
f = A("f")
n = C("n")

l.r = e
l.s = h
l.p = h
e.z = j
e.x = n
h.o = n
d.z = j
d.x = n
k.z = f
k.x = n
j.r = d
j.s = n
j.p = h
c.z = j
c.x = n
f.r = k
f.s = n
f.p = h
n.o = h
assert h.o.o.o.o.o.o.txt == "h"