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

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

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

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

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

m.x = g
f.y = a
f.q = a
f.u = a
f.x = a
k.y = a
k.x = f
k.s = f
a.u = f
a.z = f
g.y = a
g.x = f
g.s = f
assert k.s.x.u.q.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

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

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

m.x = g
f.y = a
f.q = a
f.u = a
f.x = a
k.y = a
k.x = f
k.s = f
a.u = f
a.z = f
g.y = a
g.x = f
g.s = f
assert k.s.x.u.q.txt == "a"