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

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

class C:
    def __init__(self, txt: str):
        self.w: B = None
        self.x: C = None
        self.o: C = None
        self.txt = txt

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

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

m.t = l
i.t = m
i.y = a
i.r = k
i.v = l
a.w = i
a.x = e
a.o = e
c.y = k
e.w = i
e.x = a
e.o = a
l.t = m
l.y = e
l.r = k
l.v = i
k.y = c
assert m.t.t.t.r.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.w: B = None
        self.x: C = None
        self.o: C = None
        self.txt = txt

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

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

m.t = l
i.t = m
i.y = a
i.r = k
i.v = l
a.w = i
a.x = e
a.o = e
c.y = k
e.w = i
e.x = a
e.o = a
l.t = m
l.y = e
l.r = k
l.v = i
k.y = c
assert m.t.t.t.r.txt == "k"