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

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

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

class D:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

e = A("e")
b = B("b")
c = C("c")
m = D("m")

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

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

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

class D:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

e = A("e")
b = B("b")
c = C("c")
m = D("m")

e.z = c
e.r = b
e.v = b
b.r = m
b.z = m
b.v = e
c.y = b
m.s = b
assert m.s.v.z.txt == "c"