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

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

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

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

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

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

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

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

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