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

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

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

a = A("a")
e = B("e")
h = C("h")
j = A("j")
b = C("b")

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

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

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

a = A("a")
e = B("e")
h = C("h")
j = A("j")
b = C("b")

a.p = j
a.v = h
e.t = j
h.z = b
j.p = a
j.v = b
b.z = h
assert h.z.z.z.txt == "b"