class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.z: C = None
        self.w: E = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

d = A("d")
l = B("l")
g = C("g")
j = D("j")
h = E("h")

d.r = l
d.z = g
d.w = h
l.z = d
l.s = g
l.u = j
g.t = j
g.q = j
g.u = l
j.s = d
h.v = j
assert h.v.s.z.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.z: C = None
        self.w: E = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

d = A("d")
l = B("l")
g = C("g")
j = D("j")
h = E("h")

d.r = l
d.z = g
d.w = h
l.z = d
l.s = g
l.u = j
g.t = j
g.q = j
g.u = l
j.s = d
h.v = j
assert h.v.s.z.txt == "g"