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

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

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

c = A("c")
h = B("h")
f = C("f")
g = C("g")

c.p = h
h.z = c
f.p = g
f.v = c
g.p = f
g.v = c
assert f.v.p.z.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

c = A("c")
h = B("h")
f = C("f")
g = C("g")

c.p = h
h.z = c
f.p = g
f.v = c
g.p = f
g.v = c
assert f.v.p.z.txt == "c"