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

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

f = A("f")
c = B("c")
b = B("b")
l = B("l")
e = B("e")
i = B("i")
d = B("d")
a = A("a")
j = B("j")
n = B("n")

f.r = l
c.x = f
b.x = f
l.x = a
e.x = f
i.x = a
d.x = f
a.r = c
j.x = a
n.x = a
assert l.x.r.x.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

f = A("f")
c = B("c")
b = B("b")
l = B("l")
e = B("e")
i = B("i")
d = B("d")
a = A("a")
j = B("j")
n = B("n")

f.r = l
c.x = f
b.x = f
l.x = a
e.x = f
i.x = a
d.x = f
a.r = c
j.x = a
n.x = a
assert l.x.r.x.txt == "f"