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

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

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

j = A("j")
i = B("i")
g = C("g")
f = C("f")
c = B("c")
a = B("a")
k = B("k")
l = A("l")

j.s = l
j.u = f
i.u = f
g.u = j
f.u = j
c.u = g
a.u = f
k.u = g
l.s = j
l.u = f
assert j.u.u.s.s.u.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.u: C = None
        self.txt = txt

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

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

j = A("j")
i = B("i")
g = C("g")
f = C("f")
c = B("c")
a = B("a")
k = B("k")
l = A("l")

j.s = l
j.u = f
i.u = f
g.u = j
f.u = j
c.u = g
a.u = f
k.u = g
l.s = j
l.u = f
assert j.u.u.s.s.u.txt == "f"