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

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

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

g = A("g")
b = B("b")
h = C("h")
k = C("k")

g.o = k
b.z = g
b.s = h
h.x = g
h.u = b
k.x = g
k.u = b
assert g.o.x.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

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

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

g = A("g")
b = B("b")
h = C("h")
k = C("k")

g.o = k
b.z = g
b.s = h
h.x = g
h.u = b
k.x = g
k.u = b
assert g.o.x.o.txt == "k"