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

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

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

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

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

a = A("a")
n = B("n")
f = C("f")
e = D("e")
h = E("h")
g = D("g")
k = E("k")

a.u = n
a.x = g
a.s = f
n.p = g
n.r = g
n.y = a
f.r = n
f.o = n
e.t = n
h.s = k
g.t = n
k.s = h
assert h.s.s.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.x: D = None
        self.s: C = None
        self.txt = txt

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

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

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

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

a = A("a")
n = B("n")
f = C("f")
e = D("e")
h = E("h")
g = D("g")
k = E("k")

a.u = n
a.x = g
a.s = f
n.p = g
n.r = g
n.y = a
f.r = n
f.o = n
e.t = n
h.s = k
g.t = n
k.s = h
assert h.s.s.s.s.s.s.txt == "h"