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

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

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

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

i = A("i")
m = B("m")
d = C("d")
b = D("b")
k = A("k")
n = C("n")
a = D("a")
l = A("l")
f = D("f")

i.s = m
m.w = d
m.v = d
d.y = i
d.w = m
d.p = f
d.v = n
b.r = m
k.s = m
n.y = l
n.w = m
n.p = b
n.v = d
a.r = m
l.s = m
f.r = m
assert f.r.v.w.v.v.p.r.v.p.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

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

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

i = A("i")
m = B("m")
d = C("d")
b = D("b")
k = A("k")
n = C("n")
a = D("a")
l = A("l")
f = D("f")

i.s = m
m.w = d
m.v = d
d.y = i
d.w = m
d.p = f
d.v = n
b.r = m
k.s = m
n.y = l
n.w = m
n.p = b
n.v = d
a.r = m
l.s = m
f.r = m
assert f.r.v.w.v.v.p.r.v.p.txt == "f"