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

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

f = A("f")
l = B("l")
g = B("g")
h = B("h")
i = B("i")
b = B("b")
k = B("k")
j = B("j")
n = B("n")

f.s = n
f.z = b
l.r = f
g.r = f
h.r = f
i.r = f
b.r = f
k.r = f
j.r = f
n.r = f
assert b.r.s.r.z.r.z.r.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.z: B = None
        self.txt = txt

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

f = A("f")
l = B("l")
g = B("g")
h = B("h")
i = B("i")
b = B("b")
k = B("k")
j = B("j")
n = B("n")

f.s = n
f.z = b
l.r = f
g.r = f
h.r = f
i.r = f
b.r = f
k.r = f
j.r = f
n.r = f
assert b.r.s.r.z.r.z.r.txt == "f"