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

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

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

h = A("h")
a = B("a")
j = C("j")
c = B("c")
k = A("k")

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

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

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

h = A("h")
a = B("a")
j = C("j")
c = B("c")
k = A("k")

h.p = j
h.v = j
h.z = a
a.s = h
j.t = a
c.s = h
k.p = j
k.v = j
k.z = a
assert a.s.z.s.z.s.txt == "h"