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

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

c = A("c")
f = B("f")
l = A("l")
n = B("n")
h = A("h")
b = A("b")

c.o = f
f.r = l
l.o = f
n.r = c
h.o = n
b.o = f
assert l.o.r.o.r.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

c = A("c")
f = B("f")
l = A("l")
n = B("n")
h = A("h")
b = A("b")

c.o = f
f.r = l
l.o = f
n.r = c
h.o = n
b.o = f
assert l.o.r.o.r.o.txt == "f"