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

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

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

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

b.u = m
m.o = g
m.z = h
m.p = b
h.z = b
h.r = b
h.s = b
g.z = b
g.r = b
g.s = b
assert b.u.o.r.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

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

b.u = m
m.o = g
m.z = h
m.p = b
h.z = b
h.r = b
h.s = b
g.z = b
g.r = b
g.s = b
assert b.u.o.r.txt == "b"