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

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

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

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

i.q = h
a.r = f
a.o = i
h.u = a
l.u = a
e.r = f
e.o = i
j.u = a
m.u = a
k.r = e
k.o = i
f.r = a
f.o = i
b.u = f
assert l.u.o.q.u.o.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

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

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

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

i.q = h
a.r = f
a.o = i
h.u = a
l.u = a
e.r = f
e.o = i
j.u = a
m.u = a
k.r = e
k.o = i
f.r = a
f.o = i
b.u = f
assert l.u.o.q.u.o.txt == "i"