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

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

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

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

d = A("d")
l = B("l")
c = C("c")
e = D("e")
a = D("a")

d.u = l
l.w = c
l.y = c
c.w = l
c.q = e
e.u = a
e.w = a
e.t = l
a.u = e
a.w = e
a.t = l
assert c.w.y.w.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

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

d = A("d")
l = B("l")
c = C("c")
e = D("e")
a = D("a")

d.u = l
l.w = c
l.y = c
c.w = l
c.q = e
e.u = a
e.w = a
e.t = l
a.u = e
a.w = e
a.t = l
assert c.w.y.w.txt == "l"