class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.z: D = None
        self.txt = txt

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

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

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

g = A("g")
j = B("j")
m = C("m")
e = D("e")

g.r = e
g.z = e
j.x = m
j.y = e
j.s = e
m.w = e
m.u = g
m.x = j
e.q = j
e.t = g
assert m.u.z.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.z: D = None
        self.txt = txt

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

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

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

g = A("g")
j = B("j")
m = C("m")
e = D("e")

g.r = e
g.z = e
j.x = m
j.y = e
j.s = e
m.w = e
m.u = g
m.x = j
e.q = j
e.t = g
assert m.u.z.q.x.txt == "m"