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

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

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

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

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

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

m.q = l
l.q = d
e.y = m
e.u = l
c.s = e
j.y = c
j.q = m
j.u = d
j.s = e
j.p = l
n.s = e
d.s = e
assert j.p.q.s.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

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

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

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

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

m.q = l
l.q = d
e.y = m
e.u = l
c.s = e
j.y = c
j.q = m
j.u = d
j.s = e
j.p = l
n.s = e
d.s = e
assert j.p.q.s.y.txt == "m"