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

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

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

j = A("j")
i = B("i")
d = C("d")

j.v = i
i.y = d
d.p = i
d.v = i
d.y = j
assert j.v.y.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

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

j = A("j")
i = B("i")
d = C("d")

j.v = i
i.y = d
d.p = i
d.v = i
d.y = j
assert j.v.y.v.txt == "i"