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

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

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

m = A("m")
i = B("i")
a = C("a")
k = B("k")
l = B("l")
d = A("d")

m.r = k
m.y = d
m.t = d
i.r = k
i.q = a
a.r = k
a.t = i
a.s = d
k.r = i
k.q = a
l.r = i
l.q = a
d.r = k
d.y = m
d.t = m
assert a.r.q.t.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.y: A = None
        self.t: A = None
        self.txt = txt

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

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

m = A("m")
i = B("i")
a = C("a")
k = B("k")
l = B("l")
d = A("d")

m.r = k
m.y = d
m.t = d
i.r = k
i.q = a
a.r = k
a.t = i
a.s = d
k.r = i
k.q = a
l.r = i
l.q = a
d.r = k
d.y = m
d.t = m
assert a.r.q.t.txt == "i"