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

class B:
    def __init__(self, txt: str):
        self.s: B = None
        self.o: B = None
        self.z: B = None
        self.p: B = None
        self.txt = txt

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

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

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

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

class B:
    def __init__(self, txt: str):
        self.s: B = None
        self.o: B = None
        self.z: B = None
        self.p: B = None
        self.txt = txt

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

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

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

a.o = j
f.s = b
f.o = m
f.z = m
f.p = m
d.y = j
d.r = l
j.v = e
e.o = j
l.y = j
l.r = d
b.s = m
b.z = m
b.p = m
b.o = f
m.s = f
m.z = f
m.o = b
m.p = b
assert d.y.v.o.v.o.v.txt == "e"