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")
j = A("j")
n = B("n")
g = B("g")
c = B("c")
a = B("a")
d = A("d")

k.s = a
h.y = j
j.s = n
n.y = k
g.y = k
c.y = j
a.y = j
d.s = h
assert d.s.y.s.y.s.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")
j = A("j")
n = B("n")
g = B("g")
c = B("c")
a = B("a")
d = A("d")

k.s = a
h.y = j
j.s = n
n.y = k
g.y = k
c.y = j
a.y = j
d.s = h
assert d.s.y.s.y.s.txt == "a"