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

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

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

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

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

h.t = k
h.z = c
k.s = c
k.v = i
i.x = k
i.o = k
i.z = k
i.s = c
c.x = h
assert i.x.v.s.x.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.z: D = None
        self.txt = txt

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

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

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

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

h.t = k
h.z = c
k.s = c
k.v = i
i.x = k
i.o = k
i.z = k
i.s = c
c.x = h
assert i.x.v.s.x.txt == "h"