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

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

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

a = A("a")
g = B("g")
i = C("i")
k = B("k")

a.w = k
a.q = i
a.v = g
g.o = a
i.r = a
i.y = a
i.s = k
k.o = a
assert a.q.s.o.q.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.q: C = None
        self.v: B = None
        self.txt = txt

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

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

a = A("a")
g = B("g")
i = C("i")
k = B("k")

a.w = k
a.q = i
a.v = g
g.o = a
i.r = a
i.y = a
i.s = k
k.o = a
assert a.q.s.o.q.txt == "i"