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

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

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

g = A("g")
c = B("c")
b = C("b")
d = A("d")

g.o = d
g.t = d
c.v = b
b.w = d
d.o = g
d.t = g
assert d.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.t: A = None
        self.txt = txt

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

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

g = A("g")
c = B("c")
b = C("b")
d = A("d")

g.o = d
g.t = d
c.v = b
b.w = d
d.o = g
d.t = g
assert d.t.t.t.txt == "g"