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

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

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

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

l = A("l")
i = B("i")
a = C("a")
j = D("j")

l.u = a
l.r = a
l.x = a
i.w = a
i.x = a
a.q = i
j.w = i
assert l.u.q.x.q.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.r: C = None
        self.x: C = None
        self.txt = txt

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

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

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

l = A("l")
i = B("i")
a = C("a")
j = D("j")

l.u = a
l.r = a
l.x = a
i.w = a
i.x = a
a.q = i
j.w = i
assert l.u.q.x.q.txt == "i"