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

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

a = A("a")
f = B("f")
c = A("c")
i = A("i")
g = A("g")

a.o = c
f.v = c
c.o = a
i.o = c
g.o = a
assert c.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

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

a = A("a")
f = B("f")
c = A("c")
i = A("i")
g = A("g")

a.o = c
f.v = c
c.o = a
i.o = c
g.o = a
assert c.o.o.o.txt == "a"