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

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

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

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

m = A("m")
i = B("i")
c = C("c")
j = D("j")
h = B("h")
a = A("a")
n = B("n")

m.s = a
i.r = m
i.p = m
i.u = j
c.v = j
c.t = j
c.z = h
c.w = a
j.w = c
j.o = h
h.r = m
h.u = j
h.p = a
a.s = m
n.r = a
n.p = a
n.u = j
assert j.w.w.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

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

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

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

m = A("m")
i = B("i")
c = C("c")
j = D("j")
h = B("h")
a = A("a")
n = B("n")

m.s = a
i.r = m
i.p = m
i.u = j
c.v = j
c.t = j
c.z = h
c.w = a
j.w = c
j.o = h
h.r = m
h.u = j
h.p = a
a.s = m
n.r = a
n.p = a
n.u = j
assert j.w.w.s.txt == "m"