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

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

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

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

n = A("n")
d = B("d")
k = C("k")
e = D("e")

n.o = k
n.v = k
n.q = e
d.r = e
d.v = k
d.w = k
k.y = d
e.o = d
e.z = d
assert k.y.r.o.v.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.q: D = None
        self.v: C = None
        self.txt = txt

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

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

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

n = A("n")
d = B("d")
k = C("k")
e = D("e")

n.o = k
n.v = k
n.q = e
d.r = e
d.v = k
d.w = k
k.y = d
e.o = d
e.z = d
assert k.y.r.o.v.txt == "k"