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

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

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

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

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

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

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

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

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

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

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