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

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

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

b = A("b")
a = B("a")
f = C("f")
g = A("g")

b.t = g
a.s = f
a.v = f
f.z = a
f.o = g
f.t = g
g.t = b
assert b.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

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

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

b = A("b")
a = B("a")
f = C("f")
g = A("g")

b.t = g
a.s = f
a.v = f
f.z = a
f.o = g
f.t = g
g.t = b
assert b.t.t.t.txt == "g"