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

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

l = A("l")
a = B("a")
f = A("f")
d = A("d")
c = B("c")

l.o = f
a.z = f
a.v = c
f.o = l
d.o = f
c.z = d
c.v = a
assert l.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.z: A = None
        self.v: B = None
        self.txt = txt

l = A("l")
a = B("a")
f = A("f")
d = A("d")
c = B("c")

l.o = f
a.z = f
a.v = c
f.o = l
d.o = f
c.z = d
c.v = a
assert l.o.o.o.txt == "f"