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

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

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

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

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

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

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

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

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

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

a.p = d
a.y = d
a.v = m
f.p = d
f.w = d
e.o = a
n.s = b
b.p = d
b.w = n
d.s = f
l.o = m
m.p = d
m.y = n
m.v = a
assert a.y.s.w.s.w.s.txt == "f"