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

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

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

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

c = A("c")
k = B("k")
a = C("a")
m = D("m")
n = A("n")
d = D("d")
l = B("l")
g = D("g")
f = D("f")
j = C("j")

c.w = m
c.u = m
k.s = a
a.r = d
m.r = a
n.w = d
n.u = g
d.r = j
l.s = a
g.r = a
f.r = j
j.r = d
assert l.s.r.r.r.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.u: D = None
        self.txt = txt

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

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

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

c = A("c")
k = B("k")
a = C("a")
m = D("m")
n = A("n")
d = D("d")
l = B("l")
g = D("g")
f = D("f")
j = C("j")

c.w = m
c.u = m
k.s = a
a.r = d
m.r = a
n.w = d
n.u = g
d.r = j
l.s = a
g.r = a
f.r = j
j.r = d
assert l.s.r.r.r.r.r.r.r.txt == "d"