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

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

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

m = A("m")
k = B("k")
f = C("f")
c = A("c")
a = C("a")
g = B("g")
i = C("i")
b = A("b")
n = C("n")

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

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

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

m = A("m")
k = B("k")
f = C("f")
c = A("c")
a = C("a")
g = B("g")
i = C("i")
b = A("b")
n = C("n")

m.x = g
m.s = f
m.p = b
k.o = m
k.x = f
k.z = b
f.r = g
c.x = g
c.s = i
c.p = m
a.r = g
g.o = b
g.x = i
g.z = m
i.r = k
b.x = g
b.s = f
b.p = m
n.r = g
assert a.r.z.p.s.txt == "f"