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

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

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

b = A("b")
f = B("f")
a = C("a")
i = C("i")
g = B("g")

b.u = f
b.q = i
b.z = g
f.y = g
f.w = g
a.o = b
i.o = b
g.y = f
g.w = f
assert f.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.q: C = None
        self.z: B = None
        self.txt = txt

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

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

b = A("b")
f = B("f")
a = C("a")
i = C("i")
g = B("g")

b.u = f
b.q = i
b.z = g
f.y = g
f.w = g
a.o = b
i.o = b
g.y = f
g.w = f
assert f.y.y.y.y.txt == "f"