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

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

k = A("k")
f = B("f")
j = B("j")
l = A("l")
m = A("m")

k.y = l
k.s = j
f.u = j
j.u = f
l.y = k
l.s = j
m.y = l
m.s = j
assert l.y.s.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.s: B = None
        self.txt = txt

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

k = A("k")
f = B("f")
j = B("j")
l = A("l")
m = A("m")

k.y = l
k.s = j
f.u = j
j.u = f
l.y = k
l.s = j
m.y = l
m.s = j
assert l.y.s.u.u.u.txt == "f"