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

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

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

b = A("b")
l = B("l")
f = C("f")
k = A("k")
c = B("c")

b.y = f
l.s = f
l.q = b
f.x = c
f.o = b
f.z = k
k.y = f
c.s = f
c.q = k
assert k.y.z.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

b = A("b")
l = B("l")
f = C("f")
k = A("k")
c = B("c")

b.y = f
l.s = f
l.q = b
f.x = c
f.o = b
f.z = k
k.y = f
c.s = f
c.q = k
assert k.y.z.y.txt == "f"