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

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

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

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

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

b.y = e
h.z = m
h.u = m
h.r = e
h.w = b
e.p = h
e.w = m
m.y = b
m.o = e
m.u = h
assert b.y.w.u.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

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

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

b.y = e
h.z = m
h.u = m
h.r = e
h.w = b
e.p = h
e.w = m
m.y = b
m.o = e
m.u = h
assert b.y.w.u.txt == "h"