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

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

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

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

h = A("h")
f = B("f")
n = C("n")
m = D("m")
d = C("d")
i = A("i")

h.z = i
h.o = d
h.x = n
f.s = n
f.w = n
f.o = m
n.u = f
n.w = f
m.z = i
m.w = d
d.u = f
d.w = f
i.z = h
i.o = n
i.x = n
assert f.o.w.u.s.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.o: C = None
        self.x: C = None
        self.txt = txt

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

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

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

h = A("h")
f = B("f")
n = C("n")
m = D("m")
d = C("d")
i = A("i")

h.z = i
h.o = d
h.x = n
f.s = n
f.w = n
f.o = m
n.u = f
n.w = f
m.z = i
m.w = d
d.u = f
d.w = f
i.z = h
i.o = n
i.x = n
assert f.o.w.u.s.w.w.txt == "n"