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

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

class C:
    def __init__(self, txt: str):
        self.y: D = None
        self.p: A = None
        self.t: A = None
        self.x: B = None
        self.txt = txt

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

a = A("a")
k = B("k")
i = C("i")
c = D("c")

a.z = k
a.v = k
a.r = i
a.t = c
k.w = a
i.y = c
i.p = a
i.t = a
i.x = k
c.o = i
assert a.t.o.x.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.v: B = None
        self.r: C = None
        self.t: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.y: D = None
        self.p: A = None
        self.t: A = None
        self.x: B = None
        self.txt = txt

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

a = A("a")
k = B("k")
i = C("i")
c = D("c")

a.z = k
a.v = k
a.r = i
a.t = c
k.w = a
i.y = c
i.p = a
i.t = a
i.x = k
c.o = i
assert a.t.o.x.txt == "k"