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

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

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

class D:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

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

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

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

class D:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

c.u = a
m.r = e
f.p = l
f.v = l
f.w = e
f.u = n
j.v = e
n.u = a
a.v = m
k.p = l
k.v = l
k.w = e
k.u = n
e.r = m
d.v = e
l.p = f
l.w = m
l.u = c
l.v = k
assert k.w.r.r.r.r.r.r.r.r.txt == "e"