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

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

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

e = A("e")
m = B("m")
b = C("b")

e.z = b
e.o = b
m.x = b
m.q = b
b.s = m
b.z = e
assert m.q.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.o: C = None
        self.txt = txt

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

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

e = A("e")
m = B("m")
b = C("b")

e.z = b
e.o = b
m.x = b
m.q = b
b.s = m
b.z = e
assert m.q.s.q.txt == "b"