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

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

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

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

m = A("m")
k = B("k")
a = C("a")
d = D("d")
g = B("g")

m.s = d
m.x = d
k.r = g
k.u = a
a.w = d
a.q = d
a.x = d
d.u = k
g.r = k
g.u = a
assert d.u.u.x.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.x: D = None
        self.txt = txt

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

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

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

m = A("m")
k = B("k")
a = C("a")
d = D("d")
g = B("g")

m.s = d
m.x = d
k.r = g
k.u = a
a.w = d
a.q = d
a.x = d
d.u = k
g.r = k
g.u = a
assert d.u.u.x.txt == "d"