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

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

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

d = A("d")
e = B("e")
i = C("i")
h = C("h")

d.x = i
e.v = i
e.p = h
i.y = h
i.w = d
i.v = d
h.y = i
h.w = d
h.v = d
assert e.v.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

d = A("d")
e = B("e")
i = C("i")
h = C("h")

d.x = i
e.v = i
e.p = h
i.y = h
i.w = d
i.v = d
h.y = i
h.w = d
h.v = d
assert e.v.y.y.txt == "i"