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

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

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

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

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

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

j.s = d
a.z = i
a.q = i
i.s = d
i.z = j
l.t = a
d.w = a
m.s = d
assert j.s.w.z.txt == "
class A:
    def __init__(self, txt: str):
        self.s: E = None
        self.txt = txt

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

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

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

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

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

j.s = d
a.z = i
a.q = i
i.s = d
i.z = j
l.t = a
d.w = a
m.s = d
assert j.s.w.z.txt == "i"