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.x: A = None
        self.txt = txt

j = A("j")
f = B("f")
n = B("n")
k = B("k")
e = B("e")

j.s = k
j.z = f
f.x = j
n.x = j
k.x = j
e.x = j
assert j.s.x.s.x.z.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.x: A = None
        self.txt = txt

j = A("j")
f = B("f")
n = B("n")
k = B("k")
e = B("e")

j.s = k
j.z = f
f.x = j
n.x = j
k.x = j
e.x = j
assert j.s.x.s.x.z.txt == "f"