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

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

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

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

g.o = a
g.t = a
a.r = i
i.q = g
assert i.q.t.r.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.t: B = None
        self.txt = txt

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

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

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

g.o = a
g.t = a
a.r = i
i.q = g
assert i.q.t.r.txt == "i"