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

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

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

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

f = A("f")
m = B("m")
c = C("c")
n = D("n")
e = B("e")
d = C("d")
k = C("k")
h = C("h")

f.w = n
m.o = h
m.p = e
m.s = f
m.u = n
c.v = f
c.z = n
c.o = k
c.w = d
n.o = e
n.s = c
e.o = h
e.p = m
e.s = f
e.u = n
d.v = f
d.z = n
d.o = k
d.w = c
k.v = f
k.z = n
k.o = d
k.w = d
h.v = f
h.z = n
h.o = k
h.w = k
assert h.v.w.s.z.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.txt = txt

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

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

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

f = A("f")
m = B("m")
c = C("c")
n = D("n")
e = B("e")
d = C("d")
k = C("k")
h = C("h")

f.w = n
m.o = h
m.p = e
m.s = f
m.u = n
c.v = f
c.z = n
c.o = k
c.w = d
n.o = e
n.s = c
e.o = h
e.p = m
e.s = f
e.u = n
d.v = f
d.z = n
d.o = k
d.w = c
k.v = f
k.z = n
k.o = d
k.w = d
h.v = f
h.z = n
h.o = k
h.w = k
assert h.v.w.s.z.txt == "n"