class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.o: C = None
        self.u: C = None
        self.txt = txt

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

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

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

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

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

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

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

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

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

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

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

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