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

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

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

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

f.x = n
n.s = h
n.y = h
h.o = f
assert h.o.x.s.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

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

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

f.x = n
n.s = h
n.y = h
h.o = f
assert h.o.x.s.txt == "h"