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

class B:
    def __init__(self, txt: str):
        self.s: A = None
        self.y: C = None
        self.q: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

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

a = A("a")
d = B("d")
l = C("l")
n = D("n")

a.s = d
a.w = n
d.s = a
d.q = a
d.y = l
l.y = n
n.w = a
n.o = l
n.y = l
assert d.q.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.w: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: A = None
        self.y: C = None
        self.q: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

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

a = A("a")
d = B("d")
l = C("l")
n = D("n")

a.s = d
a.w = n
d.s = a
d.q = a
d.y = l
l.y = n
n.w = a
n.o = l
n.y = l
assert d.q.w.w.w.txt == "n"