class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.s: C = None
        self.q: B = None
        self.y: D = None
        self.txt = txt

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

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

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

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

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

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

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

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

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

c.w = e
c.y = e
c.s = d
c.q = m
m.q = c
m.z = c
m.v = d
d.r = c
d.o = c
d.u = e
e.r = m
assert d.r.q.z.txt == "c"