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

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

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

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

d = A("d")
e = B("e")
b = C("b")
c = D("c")

d.u = b
d.p = b
e.w = d
b.u = e
c.t = d
c.s = e
c.v = e
c.q = e
assert c.t.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.p: C = None
        self.txt = txt

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

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

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

d = A("d")
e = B("e")
b = C("b")
c = D("c")

d.u = b
d.p = b
e.w = d
b.u = e
c.t = d
c.s = e
c.v = e
c.q = e
assert c.t.u.u.txt == "e"