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

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

b = A("b")
k = B("k")
h = A("h")
c = B("c")
n = B("n")
j = B("j")
a = B("a")
l = B("l")
f = A("f")
m = A("m")

b.y = m
k.s = c
h.y = f
c.s = n
n.s = j
j.s = c
a.s = c
l.s = k
f.y = m
m.y = f
assert c.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

b = A("b")
k = B("k")
h = A("h")
c = B("c")
n = B("n")
j = B("j")
a = B("a")
l = B("l")
f = A("f")
m = A("m")

b.y = m
k.s = c
h.y = f
c.s = n
n.s = j
j.s = c
a.s = c
l.s = k
f.y = m
m.y = f
assert c.s.s.s.s.txt == "n"