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

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

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

d = A("d")
m = B("m")
e = C("e")

d.z = m
d.r = e
m.z = e
m.v = e
m.r = e
e.u = d
e.y = d
assert d.z.v.y.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.r: C = None
        self.txt = txt

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

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

d = A("d")
m = B("m")
e = C("e")

d.z = m
d.r = e
m.z = e
m.v = e
m.r = e
e.u = d
e.y = d
assert d.z.v.y.txt == "d"