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

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

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

f = A("f")
a = B("a")
b = C("b")
j = B("j")

f.u = b
a.z = f
a.o = f
a.u = j
b.p = f
b.w = f
j.z = f
j.o = f
j.u = a
assert f.u.w.u.w.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

f = A("f")
a = B("a")
b = C("b")
j = B("j")

f.u = b
a.z = f
a.o = f
a.u = j
b.p = f
b.w = f
j.z = f
j.o = f
j.u = a
assert f.u.w.u.w.txt == "f"