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

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

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

h = A("h")
c = B("c")
f = C("f")
b = C("b")

h.u = c
h.r = f
c.o = b
c.s = h
f.w = b
b.w = f
assert f.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.r: C = None
        self.txt = txt

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

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

h = A("h")
c = B("c")
f = C("f")
b = C("b")

h.u = c
h.r = f
c.o = b
c.s = h
f.w = b
b.w = f
assert f.w.w.w.w.txt == "f"