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

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

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

f = A("f")
c = B("c")
n = C("n")
g = C("g")

f.o = n
c.o = g
c.t = n
n.o = g
g.o = n
assert n.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

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

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

f = A("f")
c = B("c")
n = C("n")
g = C("g")

f.o = n
c.o = g
c.t = n
n.o = g
g.o = n
assert n.o.o.o.txt == "g"