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

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

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

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

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

h = A("h")
c = B("c")
k = C("k")
i = D("i")
d = E("d")
b = E("b")

h.u = d
c.z = d
k.t = c
k.o = i
i.u = k
i.p = k
d.z = c
d.t = c
d.x = h
d.y = h
b.z = c
b.t = c
b.x = h
b.y = h
assert k.t.z.x.txt == "
class A:
    def __init__(self, txt: str):
        self.u: E = None
        self.txt = txt

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

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

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

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

h = A("h")
c = B("c")
k = C("k")
i = D("i")
d = E("d")
b = E("b")

h.u = d
c.z = d
k.t = c
k.o = i
i.u = k
i.p = k
d.z = c
d.t = c
d.x = h
d.y = h
b.z = c
b.t = c
b.x = h
b.y = h
assert k.t.z.x.txt == "h"