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

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

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

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

h = A("h")
n = B("n")
j = C("j")
d = D("d")

h.z = j
n.o = d
n.p = j
n.w = h
n.s = h
j.t = d
j.r = d
d.t = j
d.z = j
d.p = j
assert h.z.r.t.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

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

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

h = A("h")
n = B("n")
j = C("j")
d = D("d")

h.z = j
n.o = d
n.p = j
n.w = h
n.s = h
j.t = d
j.r = d
d.t = j
d.z = j
d.p = j
assert h.z.r.t.txt == "j"