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

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

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

a = A("a")
l = B("l")
e = C("e")
m = A("m")
b = B("b")
d = C("d")
g = B("g")
f = C("f")
i = B("i")

a.t = l
a.q = g
a.r = d
l.t = m
e.y = d
e.p = m
m.t = l
m.q = g
m.r = e
b.t = m
d.y = e
d.p = m
g.t = m
f.y = e
f.p = m
i.t = m
assert m.q.t.q.t.q.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.q: B = None
        self.r: C = None
        self.txt = txt

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

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

a = A("a")
l = B("l")
e = C("e")
m = A("m")
b = B("b")
d = C("d")
g = B("g")
f = C("f")
i = B("i")

a.t = l
a.q = g
a.r = d
l.t = m
e.y = d
e.p = m
m.t = l
m.q = g
m.r = e
b.t = m
d.y = e
d.p = m
g.t = m
f.y = e
f.p = m
i.t = m
assert m.q.t.q.t.q.t.txt == "m"