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

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

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

a = A("a")
b = B("b")
g = C("g")
c = B("c")
i = C("i")

a.v = c
a.z = c
a.q = g
b.o = a
b.q = a
g.y = i
g.t = i
g.s = i
c.o = a
c.q = a
i.y = g
i.t = g
i.s = g
assert a.z.q.q.s.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.z: B = None
        self.q: C = None
        self.txt = txt

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

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

a = A("a")
b = B("b")
g = C("g")
c = B("c")
i = C("i")

a.v = c
a.z = c
a.q = g
b.o = a
b.q = a
g.y = i
g.t = i
g.s = i
c.o = a
c.q = a
i.y = g
i.t = g
i.s = g
assert a.z.q.q.s.txt == "i"