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

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

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

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

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

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

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

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

a.v = e
a.t = h
h.v = e
e.p = a
assert a.t.v.p.txt == "a"