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

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

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

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

c.t = k
l.q = e
j.p = m
j.u = m
j.o = i
i.p = c
i.u = c
i.o = j
h.q = i
m.t = a
k.q = i
e.p = c
e.o = i
e.u = m
a.q = e
assert j.p.t.q.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

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

c.t = k
l.q = e
j.p = m
j.u = m
j.o = i
i.p = c
i.u = c
i.o = j
h.q = i
m.t = a
k.q = i
e.p = c
e.o = i
e.u = m
a.q = e
assert j.p.t.q.txt == "e"