class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.z: C = None
        self.q: D = None
        self.r: C = None
        self.txt = txt

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

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

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

d = A("d")
k = B("k")
i = C("i")
m = D("m")

d.v = k
d.z = i
d.r = i
d.q = m
k.z = i
i.z = k
i.w = d
i.o = m
m.x = i
assert i.w.r.o.x.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.z: C = None
        self.q: D = None
        self.r: C = None
        self.txt = txt

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

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

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

d = A("d")
k = B("k")
i = C("i")
m = D("m")

d.v = k
d.z = i
d.r = i
d.q = m
k.z = i
i.z = k
i.w = d
i.o = m
m.x = i
assert i.w.r.o.x.txt == "i"