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

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

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

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

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

n = A("n")
a = B("a")
l = C("l")
d = D("d")
i = E("i")
j = A("j")

n.q = i
n.u = d
a.r = n
a.w = i
l.u = i
l.s = d
l.r = d
d.x = i
i.s = d
i.q = l
i.w = j
j.q = i
j.u = d
assert i.s.x.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: E = None
        self.u: D = None
        self.txt = txt

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

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

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

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

n = A("n")
a = B("a")
l = C("l")
d = D("d")
i = E("i")
j = A("j")

n.q = i
n.u = d
a.r = n
a.w = i
l.u = i
l.s = d
l.r = d
d.x = i
i.s = d
i.q = l
i.w = j
j.q = i
j.u = d
assert i.s.x.q.txt == "l"