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

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

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

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

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

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

n.u = g
n.s = l
k.q = l
l.s = g
l.y = g
l.q = n
g.q = i
g.p = i
g.x = i
g.z = l
i.x = g
assert k.q.s.z.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.s: C = None
        self.txt = txt

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

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

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

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

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

n.u = g
n.s = l
k.q = l
l.s = g
l.y = g
l.q = n
g.q = i
g.p = i
g.x = i
g.z = l
i.x = g
assert k.q.s.z.txt == "l"