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

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

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

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

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

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

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

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

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

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

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