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

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

j = A("j")
h = B("h")
l = A("l")
k = A("k")

j.s = l
h.v = j
l.s = k
k.s = l
assert j.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

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

j = A("j")
h = B("h")
l = A("l")
k = A("k")

j.s = l
h.v = j
l.s = k
k.s = l
assert j.s.s.s.s.txt == "k"