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

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

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

c = A("c")
b = B("b")
h = C("h")
m = C("m")
j = C("j")
k = C("k")
l = C("l")
e = C("e")
g = C("g")
n = A("n")

c.q = e
c.y = n
b.u = c
h.t = k
m.t = l
j.t = k
k.t = m
l.t = j
e.t = j
g.t = e
n.q = e
n.y = c
assert b.u.q.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.y: A = None
        self.txt = txt

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

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

c = A("c")
b = B("b")
h = C("h")
m = C("m")
j = C("j")
k = C("k")
l = C("l")
e = C("e")
g = C("g")
n = A("n")

c.q = e
c.y = n
b.u = c
h.t = k
m.t = l
j.t = k
k.t = m
l.t = j
e.t = j
g.t = e
n.q = e
n.y = c
assert b.u.q.t.t.t.txt == "m"