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

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

h.y = m
n.s = k
l.s = f
f.s = l
k.s = n
e.s = f
m.y = h
j.y = c
c.y = h
assert k.s.s.s.s.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

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

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