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

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

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

c = A("c")
h = B("h")
m = C("m")
a = C("a")

c.t = a
h.o = a
m.z = c
m.x = h
a.z = c
a.x = h
assert m.z.t.x.o.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

c = A("c")
h = B("h")
m = C("m")
a = C("a")

c.t = a
h.o = a
m.z = c
m.x = h
a.z = c
a.x = h
assert m.z.t.x.o.txt == "a"