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

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

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

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

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

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

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

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

a.x = l
i.p = g
i.o = l
f.u = l
j.x = f
g.p = i
g.o = l
l.u = f
assert a.x.u.u.u.u.u.txt == "f"