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

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

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

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

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

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

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

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

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

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

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