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

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

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

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

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

b.y = m
n.y = e
n.u = e
n.o = b
n.x = m
e.r = m
e.x = m
e.y = n
e.s = n
m.w = e
assert e.y.x.w.x.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

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

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

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

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

b.y = m
n.y = e
n.u = e
n.o = b
n.x = m
e.r = m
e.x = m
e.y = n
e.s = n
m.w = e
assert e.y.x.w.x.txt == "m"