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

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

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

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

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

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

k.s = l
h.y = k
n.y = d
d.s = h
l.y = k
j.y = d
assert j.y.s.y.txt == "k"