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

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

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

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

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

i.w = e
i.p = e
f.v = m
b.y = c
c.w = i
m.w = i
e.w = i
e.p = i
d.y = c
l.y = c
assert m.w.w.p.p.w.p.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.p: A = None
        self.txt = txt

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

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

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

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

i.w = e
i.p = e
f.v = m
b.y = c
c.w = i
m.w = i
e.w = i
e.p = i
d.y = c
l.y = c
assert m.w.w.p.p.w.p.txt == "e"