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

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

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

b = A("b")
l = B("l")
g = C("g")

b.z = l
b.q = l
l.p = g
l.o = g
l.x = g
g.y = l
g.x = l
g.r = b
assert g.r.q.o.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.q: B = None
        self.txt = txt

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

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

b = A("b")
l = B("l")
g = C("g")

b.z = l
b.q = l
l.p = g
l.o = g
l.x = g
g.y = l
g.x = l
g.r = b
assert g.r.q.o.txt == "g"