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

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

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

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

m = A("m")
b = B("b")
l = C("l")
h = D("h")
j = A("j")
d = C("d")
n = A("n")
e = C("e")

m.w = b
m.r = n
b.s = d
b.y = d
b.z = d
b.u = d
l.w = j
h.o = l
j.w = b
j.r = m
d.w = j
n.w = b
n.r = m
e.w = j
assert n.r.r.r.w.s.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.r: A = None
        self.txt = txt

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

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

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

m = A("m")
b = B("b")
l = C("l")
h = D("h")
j = A("j")
d = C("d")
n = A("n")
e = C("e")

m.w = b
m.r = n
b.s = d
b.y = d
b.z = d
b.u = d
l.w = j
h.o = l
j.w = b
j.r = m
d.w = j
n.w = b
n.r = m
e.w = j
assert n.r.r.r.w.s.txt == "d"