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

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

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

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

d = A("d")
l = B("l")
m = C("m")
i = D("i")

d.x = l
d.s = l
l.r = m
l.v = m
m.q = i
i.t = l
i.x = m
assert l.v.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.s: B = None
        self.txt = txt

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

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

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

d = A("d")
l = B("l")
m = C("m")
i = D("i")

d.x = l
d.s = l
l.r = m
l.v = m
m.q = i
i.t = l
i.x = m
assert l.v.q.x.txt == "m"