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

class B:
    def __init__(self, txt: str):
        self.y: E = None
        self.x: E = None
        self.o: D = None
        self.t: A = None
        self.w: E = None
        self.txt = txt

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

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

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

l = A("l")
n = B("n")
m = C("m")
e = D("e")
j = E("j")

l.s = m
l.z = e
l.q = e
n.y = j
n.x = j
n.w = j
n.o = e
n.t = l
m.p = j
e.q = m
e.z = n
j.s = m
j.p = e
assert j.s.p.p.q.p.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.z: D = None
        self.q: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: E = None
        self.x: E = None
        self.o: D = None
        self.t: A = None
        self.w: E = None
        self.txt = txt

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

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

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

l = A("l")
n = B("n")
m = C("m")
e = D("e")
j = E("j")

l.s = m
l.z = e
l.q = e
n.y = j
n.x = j
n.w = j
n.o = e
n.t = l
m.p = j
e.q = m
e.z = n
j.s = m
j.p = e
assert j.s.p.p.q.p.txt == "j"