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

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

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

j = A("j")
h = B("h")
k = C("k")
f = A("f")

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

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

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

j = A("j")
h = B("h")
k = C("k")
f = A("f")

j.v = k
h.s = k
h.z = k
h.p = k
k.v = h
f.v = k
assert f.v.v.p.txt == "k"