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

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

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

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

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

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

i.r = d
i.q = a
d.w = a
e.y = l
e.q = l
e.w = a
a.t = d
a.r = i
l.x = a
l.r = e
l.s = d
l.q = d
assert d.w.r.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.q: D = None
        self.txt = txt

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

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

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

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

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

i.r = d
i.q = a
d.w = a
e.y = l
e.q = l
e.w = a
a.t = d
a.r = i
l.x = a
l.r = e
l.s = d
l.q = d
assert d.w.r.q.txt == "a"