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

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

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

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

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

k = A("k")
n = B("n")
h = C("h")
e = D("e")
d = E("d")
a = C("a")
l = C("l")

k.t = d
n.q = d
n.v = k
n.u = k
h.x = n
e.z = l
d.r = h
a.x = n
l.x = n
assert a.x.q.r.x.txt == "
class A:
    def __init__(self, txt: str):
        self.t: E = None
        self.txt = txt

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

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

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

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

k = A("k")
n = B("n")
h = C("h")
e = D("e")
d = E("d")
a = C("a")
l = C("l")

k.t = d
n.q = d
n.v = k
n.u = k
h.x = n
e.z = l
d.r = h
a.x = n
l.x = n
assert a.x.q.r.x.txt == "n"