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

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

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

g = A("g")
f = B("f")
c = C("c")

g.q = f
g.y = c
f.x = g
f.r = g
f.o = c
c.w = g
c.z = g
c.t = f
assert f.o.w.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.y: C = None
        self.txt = txt

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

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

g = A("g")
f = B("f")
c = C("c")

g.q = f
g.y = c
f.x = g
f.r = g
f.o = c
c.w = g
c.z = g
c.t = f
assert f.o.w.y.txt == "c"