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

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

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

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

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

a = A("a")
n = B("n")
d = C("d")
f = D("f")
h = E("h")

a.w = n
a.r = f
n.q = d
n.x = f
d.t = h
d.z = h
d.u = n
f.u = a
h.z = a
assert a.r.u.r.u.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.r: D = None
        self.txt = txt

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

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

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

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

a = A("a")
n = B("n")
d = C("d")
f = D("f")
h = E("h")

a.w = n
a.r = f
n.q = d
n.x = f
d.t = h
d.z = h
d.u = n
f.u = a
h.z = a
assert a.r.u.r.u.w.txt == "n"