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

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

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

e = A("e")
g = B("g")
a = C("a")

e.z = g
g.x = a
a.o = e
a.w = g
assert a.o.z.x.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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

e = A("e")
g = B("g")
a = C("a")

e.z = g
g.x = a
a.o = e
a.w = g
assert a.o.z.x.txt == "a"