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

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

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

k = A("k")
h = B("h")
f = C("f")

k.o = f
k.s = f
k.x = f
h.p = f
h.y = k
h.v = k
f.u = h
f.s = k
assert h.p.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.s: C = None
        self.x: C = None
        self.txt = txt

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

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

k = A("k")
h = B("h")
f = C("f")

k.o = f
k.s = f
k.x = f
h.p = f
h.y = k
h.v = k
f.u = h
f.s = k
assert h.p.s.s.txt == "f"