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

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

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

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

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

e = A("e")
n = B("n")
k = C("k")
l = D("l")
g = E("g")

e.y = k
n.y = k
n.r = g
k.u = n
l.z = k
l.y = k
l.u = g
g.t = e
g.p = e
g.u = k
assert l.z.u.y.u.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

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

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

e = A("e")
n = B("n")
k = C("k")
l = D("l")
g = E("g")

e.y = k
n.y = k
n.r = g
k.u = n
l.z = k
l.y = k
l.u = g
g.t = e
g.p = e
g.u = k
assert l.z.u.y.u.txt == "n"