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

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

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

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

h.t = c
h.v = c
c.p = k
c.y = h
k.y = h
k.p = c
assert k.y.t.y.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.v: B = None
        self.txt = txt

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

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

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

h.t = c
h.v = c
c.p = k
c.y = h
k.y = h
k.p = c
assert k.y.t.y.txt == "h"