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

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

f = A("f")
a = B("a")
d = B("d")
e = A("e")
l = B("l")
m = A("m")
b = A("b")

f.v = b
a.o = e
a.p = b
d.o = e
d.p = f
e.v = m
l.o = b
l.p = f
m.v = f
b.v = m
assert e.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

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

f = A("f")
a = B("a")
d = B("d")
e = A("e")
l = B("l")
m = A("m")
b = A("b")

f.v = b
a.o = e
a.p = b
d.o = e
d.p = f
e.v = m
l.o = b
l.p = f
m.v = f
b.v = m
assert e.v.v.v.txt == "b"