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

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

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

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

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

n.w = b
n.x = a
j.x = b
j.z = a
j.o = i
b.v = a
b.t = a
b.w = j
a.s = j
a.p = n
a.w = m
m.w = b
m.x = a
i.x = b
i.z = a
i.o = j
assert j.z.w.x.w.x.s.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.x: D = None
        self.txt = txt

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

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

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

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

n.w = b
n.x = a
j.x = b
j.z = a
j.o = i
b.v = a
b.t = a
b.w = j
a.s = j
a.p = n
a.w = m
m.w = b
m.x = a
i.x = b
i.z = a
i.o = j
assert j.z.w.x.w.x.s.txt == "j"