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

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

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

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

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

h = A("h")
f = B("f")
a = C("a")
d = D("d")
g = E("g")
b = B("b")
i = B("i")
e = A("e")
n = D("n")

h.r = g
f.o = n
a.u = f
a.y = e
d.u = n
g.z = n
b.o = n
i.o = d
e.r = g
n.u = d
assert f.o.u.u.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.r: E = None
        self.txt = txt

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

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

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

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

h = A("h")
f = B("f")
a = C("a")
d = D("d")
g = E("g")
b = B("b")
i = B("i")
e = A("e")
n = D("n")

h.r = g
f.o = n
a.u = f
a.y = e
d.u = n
g.z = n
b.o = n
i.o = d
e.r = g
n.u = d
assert f.o.u.u.u.u.u.u.txt == "n"