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

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

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

e = A("e")
m = B("m")
a = C("a")
f = C("f")
k = C("k")
g = B("g")

e.w = a
e.x = a
m.p = k
m.s = e
m.t = g
a.z = k
f.z = a
k.z = a
g.p = k
g.s = e
g.t = m
assert m.t.p.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.x: C = None
        self.txt = txt

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

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

e = A("e")
m = B("m")
a = C("a")
f = C("f")
k = C("k")
g = B("g")

e.w = a
e.x = a
m.p = k
m.s = e
m.t = g
a.z = k
f.z = a
k.z = a
g.p = k
g.s = e
g.t = m
assert m.t.p.z.z.z.z.txt == "k"