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

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

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

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

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

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

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

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

g.q = a
g.s = l
a.t = i
a.z = i
i.v = g
i.z = l
i.q = l
l.q = a
l.s = g
assert g.s.s.s.q.txt == "a"