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

class B:
    def __init__(self, txt: str):
        self.r: B = None
        self.s: A = None
        self.v: D = None
        self.o: C = None
        self.txt = txt

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

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

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

l.z = d
j.r = k
j.s = l
j.v = b
j.o = n
m.x = c
m.s = n
m.w = l
b.w = m
k.r = j
k.s = l
k.v = b
k.o = n
n.x = k
n.s = m
n.w = l
h.w = m
d.w = m
c.r = k
c.s = l
c.v = h
c.o = m
e.w = m
assert l.z.w.w.z.w.w.z.w.x.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.r: B = None
        self.s: A = None
        self.v: D = None
        self.o: C = None
        self.txt = txt

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

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

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

l.z = d
j.r = k
j.s = l
j.v = b
j.o = n
m.x = c
m.s = n
m.w = l
b.w = m
k.r = j
k.s = l
k.v = b
k.o = n
n.x = k
n.s = m
n.w = l
h.w = m
d.w = m
c.r = k
c.s = l
c.v = h
c.o = m
e.w = m
assert l.z.w.w.z.w.w.z.w.x.txt == "c"