class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.t: D = None
        self.x: B = None
        self.txt = txt

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

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

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

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

m.w = e
m.x = e
m.t = d
e.y = m
e.r = m
e.u = l
e.v = l
l.p = e
l.z = d
l.y = d
l.w = m
d.o = m
assert m.x.r.t.o.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.t: D = None
        self.x: B = None
        self.txt = txt

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

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

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

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

m.w = e
m.x = e
m.t = d
e.y = m
e.r = m
e.u = l
e.v = l
l.p = e
l.z = d
l.y = d
l.w = m
d.o = m
assert m.x.r.t.o.txt == "m"