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

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

c = A("c")
e = B("e")
l = B("l")
f = B("f")
g = A("g")

c.o = g
e.p = f
l.p = e
f.p = l
g.o = c
assert g.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.p: B = None
        self.txt = txt

c = A("c")
e = B("e")
l = B("l")
f = B("f")
g = A("g")

c.o = g
e.p = f
l.p = e
f.p = l
g.o = c
assert g.o.o.o.txt == "c"