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

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

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

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

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

c.w = n
c.o = j
i.s = a
i.x = a
i.w = f
j.z = n
j.s = a
a.r = j
a.q = i
a.w = i
a.x = i
n.w = f
n.o = j
f.w = c
f.o = j
assert j.s.w.w.w.o.z.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.o: C = None
        self.txt = txt

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

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

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

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

c.w = n
c.o = j
i.s = a
i.x = a
i.w = f
j.z = n
j.s = a
a.r = j
a.q = i
a.w = i
a.x = i
n.w = f
n.o = j
f.w = c
f.o = j
assert j.s.w.w.w.o.z.txt == "n"