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

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

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

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

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

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

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

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

c.t = j
d.v = i
d.p = b
b.y = c
i.v = d
i.p = b
j.t = c
assert d.v.p.y.t.t.txt == "c"