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

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

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

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

j.r = l
j.o = e
e.q = j
m.w = l
l.w = k
h.q = j
k.w = n
n.w = k
a.q = j
assert k.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.o: B = None
        self.txt = txt

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

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

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

j.r = l
j.o = e
e.q = j
m.w = l
l.w = k
h.q = j
k.w = n
n.w = k
a.q = j
assert k.w.w.w.w.txt == "k"