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

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

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

g = A("g")
k = B("k")
i = C("i")
l = B("l")
m = C("m")
c = C("c")
f = B("f")
d = B("d")

g.r = c
k.p = d
k.z = d
k.o = f
i.x = m
i.z = d
l.p = d
l.z = d
l.o = k
m.x = i
m.z = k
c.x = m
c.z = k
f.p = k
f.o = k
f.z = d
d.p = f
d.z = k
d.o = k
assert m.x.z.z.p.p.o.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

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

g = A("g")
k = B("k")
i = C("i")
l = B("l")
m = C("m")
c = C("c")
f = B("f")
d = B("d")

g.r = c
k.p = d
k.z = d
k.o = f
i.x = m
i.z = d
l.p = d
l.z = d
l.o = k
m.x = i
m.z = k
c.x = m
c.z = k
f.p = k
f.o = k
f.z = d
d.p = f
d.z = k
d.o = k
assert m.x.z.z.p.p.o.txt == "k"