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

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

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

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

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

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

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

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

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

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

e.v = b
m.o = c
m.v = c
c.z = m
b.r = e
i.r = e
assert m.o.z.o.z.txt == "m"