class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.w: A = 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.t: A = None
        self.x: A = None
        self.p: B = None
        self.txt = txt

d = A("d")
b = B("b")
e = C("e")
n = A("n")

d.z = e
d.w = n
b.v = e
e.t = d
e.x = d
e.p = b
n.z = e
n.w = d
assert b.v.p.v.p.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.w: A = 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.t: A = None
        self.x: A = None
        self.p: B = None
        self.txt = txt

d = A("d")
b = B("b")
e = C("e")
n = A("n")

d.z = e
d.w = n
b.v = e
e.t = d
e.x = d
e.p = b
n.z = e
n.w = d
assert b.v.p.v.p.txt == "b"