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

class B:
    def __init__(self, txt: str):
        self.u: C = None
        self.o: D = None
        self.y: D = None
        self.v: C = None
        self.s: E = None
        self.txt = txt

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

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

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

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

f.r = h
d.u = g
d.v = g
d.o = c
d.y = c
d.s = h
g.o = c
g.u = c
g.x = c
g.q = h
c.v = e
h.u = g
h.o = d
h.z = f
h.y = c
e.u = g
e.o = d
e.z = f
e.y = c
assert h.y.v.y.v.txt == "
class A:
    def __init__(self, txt: str):
        self.r: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: C = None
        self.o: D = None
        self.y: D = None
        self.v: C = None
        self.s: E = None
        self.txt = txt

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

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

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

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

f.r = h
d.u = g
d.v = g
d.o = c
d.y = c
d.s = h
g.o = c
g.u = c
g.x = c
g.q = h
c.v = e
h.u = g
h.o = d
h.z = f
h.y = c
e.u = g
e.o = d
e.z = f
e.y = c
assert h.y.v.y.v.txt == "e"