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

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

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

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

l.q = d
l.r = a
a.o = h
a.u = m
a.t = d
m.t = e
m.s = a
h.q = d
h.r = g
g.o = d
g.u = b
g.t = l
e.t = m
e.s = a
b.t = m
b.s = a
d.q = h
d.r = a
assert d.r.t.q.r.t.q.r.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.r: B = None
        self.txt = txt

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

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

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

l.q = d
l.r = a
a.o = h
a.u = m
a.t = d
m.t = e
m.s = a
h.q = d
h.r = g
g.o = d
g.u = b
g.t = l
e.t = m
e.s = a
b.t = m
b.s = a
d.q = h
d.r = a
assert d.r.t.q.r.t.q.r.txt == "a"