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

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

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

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

d = A("d")
g = B("g")
i = C("i")
c = D("c")
e = A("e")

d.w = c
d.u = i
d.x = i
g.p = c
i.s = g
i.q = g
i.t = d
c.z = i
e.w = c
e.u = i
e.x = i
assert e.u.q.p.z.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.u: C = None
        self.x: C = None
        self.txt = txt

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

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

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

d = A("d")
g = B("g")
i = C("i")
c = D("c")
e = A("e")

d.w = c
d.u = i
d.x = i
g.p = c
i.s = g
i.q = g
i.t = d
c.z = i
e.w = c
e.u = i
e.x = i
assert e.u.q.p.z.txt == "i"