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

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

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

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

e = A("e")
b = B("b")
m = C("m")
k = D("k")
f = A("f")
d = A("d")
c = D("c")
l = C("l")

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

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

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

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

e = A("e")
b = B("b")
m = C("m")
k = D("k")
f = A("f")
d = A("d")
c = D("c")
l = C("l")

e.r = l
b.u = e
m.x = l
m.v = l
m.w = c
k.p = c
k.u = c
f.r = l
d.r = m
c.p = k
c.u = k
l.x = m
l.v = m
l.w = k
assert b.u.r.w.u.u.p.u.p.txt == "c"