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

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

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

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

h = A("h")
a = B("a")
l = C("l")
n = D("n")

h.o = n
h.z = n
h.s = a
a.z = n
a.o = n
a.r = l
l.w = h
n.y = l
assert l.w.s.r.w.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.z: D = None
        self.s: B = None
        self.txt = txt

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

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

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

h = A("h")
a = B("a")
l = C("l")
n = D("n")

h.o = n
h.z = n
h.s = a
a.z = n
a.o = n
a.r = l
l.w = h
n.y = l
assert l.w.s.r.w.txt == "h"