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

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

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

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

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

m = A("m")
c = B("c")
a = C("a")
l = D("l")
k = E("k")
e = D("e")
d = E("d")

m.r = a
m.t = l
c.y = k
c.w = l
a.q = m
l.t = m
l.y = a
k.v = a
e.t = m
e.y = a
d.v = a
assert a.q.r.q.r.q.t.y.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.t: D = None
        self.txt = txt

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

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

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

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

m = A("m")
c = B("c")
a = C("a")
l = D("l")
k = E("k")
e = D("e")
d = E("d")

m.r = a
m.t = l
c.y = k
c.w = l
a.q = m
l.t = m
l.y = a
k.v = a
e.t = m
e.y = a
d.v = a
assert a.q.r.q.r.q.t.y.txt == "a"