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

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

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

c = A("c")
e = B("e")
h = C("h")
k = C("k")
g = A("g")
m = A("m")

c.p = k
c.v = k
e.z = k
e.s = c
h.v = e
h.t = e
h.z = k
k.v = e
k.t = e
k.z = h
g.p = h
g.v = h
m.p = k
m.v = k
assert e.s.v.v.s.v.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.v: C = None
        self.txt = txt

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

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

c = A("c")
e = B("e")
h = C("h")
k = C("k")
g = A("g")
m = A("m")

c.p = k
c.v = k
e.z = k
e.s = c
h.v = e
h.t = e
h.z = k
k.v = e
k.t = e
k.z = h
g.p = h
g.v = h
m.p = k
m.v = k
assert e.s.v.v.s.v.txt == "k"