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

e = A("e")
f = B("f")
k = A("k")
b = B("b")

e.o = k
f.v = e
k.o = e
b.v = e
assert e.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

e = A("e")
f = B("f")
k = A("k")
b = B("b")

e.o = k
f.v = e
k.o = e
b.v = e
assert e.o.o.o.txt == "k"