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

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

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

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

e = A("e")
b = B("b")
j = C("j")
m = D("m")
n = D("n")
f = D("f")
i = C("i")
d = C("d")

e.o = n
b.z = m
j.r = i
m.v = b
n.v = b
f.v = b
i.r = j
d.r = i
assert b.z.v.z.v.z.v.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.txt = txt

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

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

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

e = A("e")
b = B("b")
j = C("j")
m = D("m")
n = D("n")
f = D("f")
i = C("i")
d = C("d")

e.o = n
b.z = m
j.r = i
m.v = b
n.v = b
f.v = b
i.r = j
d.r = i
assert b.z.v.z.v.z.v.txt == "b"