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

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

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

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

k.x = i
k.o = f
k.p = j
f.z = j
f.o = j
c.p = k
c.y = f
c.u = m
j.z = f
j.o = m
m.z = j
m.o = j
i.x = k
i.o = m
i.p = m
g.p = i
g.y = j
g.u = m
assert f.o.z.z.o.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.o: B = None
        self.p: B = None
        self.txt = txt

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

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

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

k.x = i
k.o = f
k.p = j
f.z = j
f.o = j
c.p = k
c.y = f
c.u = m
j.z = f
j.o = m
m.z = j
m.o = j
i.x = k
i.o = m
i.p = m
g.p = i
g.y = j
g.u = m
assert f.o.z.z.o.txt == "m"