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

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

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

j = A("j")
f = B("f")
l = C("l")
a = A("a")
h = C("h")
k = B("k")
g = C("g")
e = B("e")

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

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

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

j = A("j")
f = B("f")
l = C("l")
a = A("a")
h = C("h")
k = B("k")
g = C("g")
e = B("e")

j.u = h
j.q = a
f.w = e
f.o = g
l.w = g
a.u = g
a.q = j
h.w = g
k.w = e
k.o = l
g.w = l
e.w = k
e.o = l
assert g.w.w.w.txt == "l"