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

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

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

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

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

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

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

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

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

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

m.p = k
d.s = j
j.v = n
j.w = f
j.s = m
n.o = c
f.p = k
l.v = n
l.w = m
l.s = f
k.o = d
c.s = j
assert m.p.o.s.v.o.s.w.txt == "f"